@@ -6,7 +6,7 @@ use geo::{
6
6
Closest , ClosestPoint , Coord , Euclidean , Length , Line , LineInterpolatePoint , LineLocatePoint ,
7
7
LineString , Point , Polygon ,
8
8
} ;
9
- use geojson:: { Feature , FeatureCollection , GeoJson } ;
9
+ use geojson:: { Feature , FeatureCollection , GeoJson , Geometry } ;
10
10
use rstar:: { primitives:: GeomWithData , RTree , AABB } ;
11
11
use serde:: Serialize ;
12
12
use utils:: { Mercator , Tags } ;
@@ -20,7 +20,7 @@ pub struct MapModel {
20
20
// All geometry stored in worldspace, including rtrees
21
21
pub mercator : Mercator ,
22
22
pub study_area_name : Option < String > ,
23
- pub boundary_polygon : Polygon ,
23
+ pub boundary_wgs84 : Polygon ,
24
24
pub closest_road : RTree < GeomWithData < LineString , RoadID > > ,
25
25
26
26
// Only those acting as severances; above or belowground don't count
@@ -87,8 +87,12 @@ pub struct Intersection {
87
87
88
88
impl MapModel {
89
89
/// Call with bytes of an osm.pbf or osm.xml string
90
- pub fn new ( input_bytes : & [ u8 ] , study_area_name : Option < String > ) -> Result < MapModel > {
91
- crate :: scrape:: scrape_osm ( input_bytes, study_area_name)
90
+ pub fn new (
91
+ input_bytes : & [ u8 ] ,
92
+ boundary_wgs84 : Polygon ,
93
+ study_area_name : Option < String > ,
94
+ ) -> Result < MapModel > {
95
+ crate :: scrape:: scrape_osm ( input_bytes, boundary_wgs84, study_area_name)
92
96
}
93
97
94
98
pub fn get_r ( & self , r : RoadID ) -> & Road {
@@ -355,7 +359,7 @@ impl MapModel {
355
359
356
360
gj. features . extend ( self . boundaries . values ( ) . cloned ( ) ) ;
357
361
358
- let mut f = self . mercator . to_wgs84_gj ( & self . boundary_polygon ) ;
362
+ let mut f = Feature :: from ( Geometry :: from ( & self . boundary_wgs84 ) ) ;
359
363
f. set_property ( "kind" , "study_area_boundary" ) ;
360
364
gj. features . push ( f) ;
361
365
@@ -486,7 +490,6 @@ impl MapModel {
486
490
487
491
/// Return a polygon covering the world, minus a hole for the boundary, in WGS84
488
492
pub fn invert_boundary ( & self ) -> Polygon {
489
- let ( boundary, _) = self . mercator . to_wgs84 ( & self . boundary_polygon ) . into_inner ( ) ;
490
493
Polygon :: new (
491
494
LineString :: from ( vec ! [
492
495
( 180.0 , 90.0 ) ,
@@ -495,7 +498,7 @@ impl MapModel {
495
498
( 180.0 , -90.0 ) ,
496
499
( 180.0 , 90.0 ) ,
497
500
] ) ,
498
- vec ! [ boundary ] ,
501
+ vec ! [ self . boundary_wgs84 . exterior ( ) . clone ( ) ] ,
499
502
)
500
503
}
501
504
0 commit comments