-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'HL/#1540-rebalancing-bis' of github.com:LBNL-UCB-STI/be…
…am into HL/#1540-rebalancing-bis
- Loading branch information
Showing
11 changed files
with
340 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package beam.utils.map | ||
|
||
import com.typesafe.scalalogging.LazyLogging | ||
import com.vividsolutions.jts.geom.Envelope | ||
import org.matsim.api.core.v01.Coord | ||
|
||
class EnvelopeToGpx extends LazyLogging { | ||
|
||
val geoUtils = new beam.sim.common.GeoUtils { | ||
override def localCRS: String = "epsg:26910" | ||
} | ||
|
||
def render(envelope: Envelope, wgsCoord: Coord, outputPath: String): Unit = { | ||
val start = System.currentTimeMillis() | ||
|
||
// We have min(x0, y0) and max(x1,y1). Need to add two extra points to draw rectangle | ||
/* | ||
min => x0,y0 | ||
max => x1,y1 | ||
x0,y1 .___________. x1,y1 | ||
| | | ||
| | | ||
| | | ||
| | | ||
x0,y0 .___________. x1, y0 | ||
*/ | ||
|
||
val envelopePoints = Array[GpxPoint]( | ||
GpxPoint("x0,y0", new Coord(envelope.getMinX, envelope.getMinY)), | ||
GpxPoint("x0,y1", new Coord(envelope.getMinX, envelope.getMaxY)), | ||
GpxPoint("x1,y1", new Coord(envelope.getMaxX, envelope.getMaxY)), | ||
GpxPoint("x1,y0", new Coord(envelope.getMaxX, envelope.getMinY)) | ||
) | ||
|
||
val gpxWriter = new GpxWriter(outputPath, geoUtils) | ||
try { | ||
|
||
val middle = GpxPoint( | ||
"Middle", | ||
new Coord((envelope.getMinX + envelope.getMaxX) / 2, (envelope.getMinY + envelope.getMaxY) / 2) | ||
) | ||
gpxWriter.drawMarker(middle) | ||
val searchPoint = GpxPoint("Search", wgsCoord) | ||
gpxWriter.drawMarker(searchPoint) | ||
gpxWriter.drawSourceToDest(middle, searchPoint) | ||
|
||
envelopePoints.foreach(point => gpxWriter.drawMarker(point)) | ||
|
||
gpxWriter.drawRectangle(envelopePoints) | ||
|
||
} finally { | ||
gpxWriter.close() | ||
} | ||
val end = System.currentTimeMillis() | ||
logger.info(s"Created '$outputPath' in ${end - start} ms") | ||
} | ||
} | ||
|
||
object EnvelopeToGpx { | ||
def longitude(coord: Coord): Double = coord.getX | ||
|
||
def latitude(coord: Coord): Double = coord.getY | ||
|
||
def main(args: Array[String]): Unit = { | ||
val en1 = new Envelope(-122.5447336, -122.3592068, 37.6989794, 37.843628) | ||
val envelopeToGpx = new EnvelopeToGpx | ||
envelopeToGpx.render(en1, new Coord(-123.180062255, 38.7728279981), "ex1.gpx") | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...la/beam/utils/GeoJsonToGpxConvertor.scala → ...eam/utils/map/GeoJsonToGpxConvertor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.