dont compare GPSBounds exactly, bc floating pt serialization problems.

add a turn restriction near uw.
This commit is contained in:
Dustin Carlino 2019-09-30 09:24:17 -07:00
parent c971a732dd
commit a539270beb
5 changed files with 73 additions and 8 deletions

View File

@ -1,11 +1,64 @@
{
"gps_bounds": {
"min_lon": -122.31036966897095,
"min_lon": -122.31036966897096,
"min_lat": 47.597290174872846,
"max_lon": -122.29152725418099,
"max_lon": -122.291527254181,
"max_lat": 47.65513966206871
},
"override_metadata": [],
"override_metadata": [
[
{
"osm_way_id": 385214478,
"node1": 31429758,
"node2": 29464758
},
[
{
"abst:endpt_back": "true",
"abst:endpt_fwd": "true",
"abst:osm_way_id": "385214478",
"highway": "primary",
"lanes": "5",
"lanes:backward": "3",
"lanes:forward": "2",
"maxspeed": "30 mph",
"name": "Montlake Boulevard Northeast",
"old_ref": "SSH 1J",
"ref": "WA 513",
"shoulder": "no",
"sidewalk": "both",
"surface": "asphalt",
"turn:lanes:backward": "left|through|through"
},
[
[
"BanTurns",
{
"osm_way_id": 385214478,
"node1": 31429758,
"node2": 29464758
}
],
[
"BanTurns",
{
"osm_way_id": 499392305,
"node1": 32103268,
"node2": 31429758
}
],
[
"BanTurns",
{
"osm_way_id": 4910588,
"node1": 29464758,
"node2": 32103268
}
]
]
]
]
],
"delete_roads": [],
"delete_intersections": [],
"add_intersections": [],

View File

@ -3,7 +3,7 @@ use aabb_quadtree::geom::{Point, Rect};
use serde_derive::{Deserialize, Serialize};
use std::f64;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Bounds {
pub min_x: f64,
pub min_y: f64,
@ -69,7 +69,7 @@ impl Bounds {
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GPSBounds {
pub(crate) min_lon: f64,
pub(crate) min_lat: f64,
@ -147,4 +147,10 @@ impl GPSBounds {
b.update(LonLat::new(-122.2421, 47.7155));
b
}
pub fn approx_eq(&self, other: &GPSBounds) -> bool {
LonLat::new(self.min_lon, self.min_lat).approx_eq(LonLat::new(other.min_lon, other.min_lat))
&& LonLat::new(self.max_lon, self.max_lat)
.approx_eq(LonLat::new(other.max_lon, other.max_lat))
}
}

View File

@ -43,6 +43,12 @@ impl LonLat {
)
.unwrap()
}
pub(crate) fn approx_eq(self, other: LonLat) -> bool {
let epsilon = 1e-8;
(self.longitude - other.longitude).abs() < epsilon
&& (self.latitude - other.latitude).abs() < epsilon
}
}
impl fmt::Display for LonLat {

View File

@ -61,7 +61,7 @@ impl Model {
if let Some(ref name) = model.edit_fixes {
if let Some(fixes) = all_fixes.remove(name) {
model.fixes = fixes;
if model.fixes.gps_bounds != model.map.gps_bounds {
if !model.fixes.gps_bounds.approx_eq(&model.map.gps_bounds) {
panic!("Can't edit {} with this map; use the original map", name);
}
}

View File

@ -127,7 +127,7 @@ impl RawMap {
for mut i in fixes.add_intersections.clone() {
// Fix up the geometry, maybe.
if self.gps_bounds != fixes.gps_bounds {
if !self.gps_bounds.approx_eq(&fixes.gps_bounds) {
i.point = Pt2D::forcibly_from_gps(
i.point.to_gps(&fixes.gps_bounds).unwrap(),
&self.gps_bounds,
@ -143,7 +143,7 @@ impl RawMap {
for mut r in fixes.add_roads.clone() {
// Fix up the geometry, maybe.
if self.gps_bounds != fixes.gps_bounds {
if !self.gps_bounds.approx_eq(&fixes.gps_bounds) {
r.center_points = self
.gps_bounds
.forcibly_convert(&fixes.gps_bounds.must_convert_back(&r.center_points));