public override GOFeature EditFeatureData(GOFeature goFeature) { IDictionary properties = goFeature.properties; if (goFeature.goFeatureType == GOFeatureType.Point) { goFeature.name = (string)goFeature.properties ["name"]; return(goFeature); } else { goFeature.name = goFeature.layer.name; } goFeature.kind = GOEnumUtils.MapboxToKind(goFeature.layer.name); goFeature.setRenderingOptions(); goFeature.y = goFeature.layer.defaultLayerY(); if (properties.Contains("_symbol")) { goFeature.y = Convert.ToInt64(properties ["_symbol"]) / 15.0f; } // float fraction = 20f; // goFeature.y = (1 + goFeature.layerIndex + goFeature.featureIndex/goFeature.featureCount)/fraction; goFeature.height = goFeature.layer.defaultRendering.polygonHeight; return(goFeature); }
public override GOFeature EditFeatureData(GOFeature goFeature) { IDictionary properties = goFeature.properties; if (goFeature.goFeatureType == GOFeatureType.Point) { goFeature.name = (string)goFeature.properties ["name"]; return(goFeature); } if (goFeature.layer != null && goFeature.layer.layerType == GOLayer.GOLayerType.Roads) { ((GORoadFeature)goFeature).isBridge = properties.Contains("brunnel") && (string)properties ["brunnel"] == "bridge"; ((GORoadFeature)goFeature).isTunnel = properties.Contains("brunnel") && (string)properties ["brunnel"] == "tunnel"; ((GORoadFeature)goFeature).isLink = properties.Contains("brunnel") && (string)properties ["brunnel"] == "link"; } goFeature.kind = GOEnumUtils.MapboxToKind((string)properties["class"]); // goFeature.y = goFeature.featureIndex/1000 + goFeature.layer.defaultLayerY(); // if (goFeature.kind == GOFeatureKind.lake) //terrible fix for vector maps without a sort value. // goFeature.y = GOLayer.defaultLayerY (GOLayer.GOLayerType.Landuse)+0.1f; float fraction = 20f; goFeature.y = (1 + goFeature.layerIndex + goFeature.featureIndex / goFeature.featureCount) / fraction; if (goFeature.kind == GOFeatureKind.lake) //terrible fix for vector maps without a sort value. { goFeature.y += 0.5f; } goFeature.setRenderingOptions(); goFeature.height = goFeature.renderingOptions.polygonHeight; if (goFeature.layer.useRealHeight && properties.Contains("render_height")) { double h = Convert.ToDouble(properties["render_height"]); goFeature.height = (float)h; } if (goFeature.layer.useRealHeight && properties.Contains("render_min_height")) { double hm = Convert.ToDouble(properties["render_min_height"]); goFeature.y = (float)hm; if (goFeature.height >= hm) { goFeature.y = (float)hm; goFeature.height = (float)goFeature.height - (float)hm; } } if (goFeature.layer.forceMinHeight && goFeature.height < goFeature.renderingOptions.polygonHeight && goFeature.y < 0.5f) { goFeature.height = goFeature.renderingOptions.polygonHeight; } return(goFeature); }
public override GOFeature EditFeatureData(GOFeature goFeature) { if (goFeature.goFeatureType == GOFeatureType.Point) { goFeature.name = (string)goFeature.properties ["name"]; return(goFeature); } IDictionary properties = goFeature.properties; if (goFeature.layer != null && goFeature.layer.layerType == GOLayer.GOLayerType.Roads) { ((GORoadFeature)goFeature).isBridge = properties.Contains("structure") && (string)properties ["structure"] == "bridge"; ((GORoadFeature)goFeature).isTunnel = properties.Contains("structure") && (string)properties ["structure"] == "tunnel"; ((GORoadFeature)goFeature).isLink = properties.Contains("structure") && (string)properties ["structure"] == "link"; } goFeature.kind = GOEnumUtils.MapboxToKind((string)properties["class"]); goFeature.name = (string)properties ["class"]; // goFeature.y = (goFeature.index / 50.0f) + goFeature.getLayerDefaultY() /150.0f; // float fraction = goFeature.layer.layerType == GOLayer.GOLayerType.Buildings? 100f:10f; float fraction = 20f; goFeature.y = (1 + goFeature.layerIndex + goFeature.featureIndex / goFeature.featureCount) / fraction; goFeature.setRenderingOptions(); goFeature.height = goFeature.renderingOptions.polygonHeight; bool extrude = properties.Contains("extrude") && (string)properties["extrude"] == "true"; if (goFeature.layer.useRealHeight && properties.Contains("height") && extrude) { double h = Convert.ToDouble(properties["height"]); goFeature.height = (float)h; } if (goFeature.layer.useRealHeight && properties.Contains("min_height") && extrude) { double minHeight = Convert.ToDouble(properties["min_height"]); goFeature.y = (float)minHeight; goFeature.height = (float)goFeature.height - (float)minHeight; } if (goFeature.height < goFeature.layer.defaultRendering.polygonHeight && goFeature.y == 0) { goFeature.height = goFeature.layer.defaultRendering.polygonHeight; } return(goFeature); }
public override GOFeature EditFeatureData(GOFeature feature) { feature.name = (string)feature.properties ["name"]; if (feature.goFeatureType == GOFeatureType.Point) { return(feature); } if (feature.GetType() == typeof(GORoadFeature)) { GORoadFeature grf = (GORoadFeature)feature; grf.kind = GOEnumUtils.MapzenToKind((string)grf.properties ["kind"]); if (grf.properties.Contains("kind_detail")) //Mapzen { grf.detail = (string)grf.properties ["kind_detail"]; } grf.isBridge = grf.properties.Contains("is_bridge") && Convert.ToBoolean(grf.properties ["is_bridge"]); grf.isTunnel = grf.properties.Contains("is_tunnel") && Convert.ToBoolean(grf.properties ["is_tunnel"]); grf.isLink = grf.properties.Contains("is_link") && Convert.ToBoolean(grf.properties ["is_link"]); } else { feature.kind = GOEnumUtils.MapzenToKind((string)feature.properties ["kind"]); if (feature.properties.Contains("kind_detail")) //Mapzen { feature.kind = GOEnumUtils.MapzenToKind((string)feature.properties ["kind_detail"]); } } // goFeature.name = Convert.ToString( properties ["id"]); feature.setRenderingOptions(); Int64 sort = 0; if (feature.properties.Contains("sort_rank")) { sort = Convert.ToInt64(feature.properties ["sort_rank"]); } else if (feature.properties.Contains("sort_key")) { sort = Convert.ToInt64(feature.properties ["sort_key"]); } feature.y = sort / 1000.0f; feature.sort = sort; feature.height = feature.renderingOptions.polygonHeight; if (feature.layer.useRealHeight && feature.properties.Contains("height")) { double h = Convert.ToDouble(feature.properties["height"]); feature.height = (float)h; } if (feature.layer.useRealHeight && feature.properties.Contains("min_height")) { double hm = Convert.ToDouble(feature.properties["min_height"]); feature.y = (float)hm; if (feature.height >= hm) { feature.y = (float)hm; feature.height = (float)feature.height - (float)hm; } } return(feature); }
public override IEnumerator BuildTile(IDictionary mapData, GOLayer layer, bool delayedLoad) { GameObject parent = new GameObject(); parent.name = layer.name; parent.transform.parent = this.transform; parent.SetActive(!layer.startInactive); if (mapData == null) { Debug.LogWarning("Map Data is null!"); #if !UNITY_WEBPLAYER FileHandler.Remove(gameObject.name); #endif yield break; } IList features = (IList)mapData ["features"]; if (features == null) { yield break; } IList stack = new List <GOFeature> (); foreach (IDictionary geo in features) { IDictionary geometry = (IDictionary)geo ["geometry"]; IDictionary properties = (IDictionary)geo ["properties"]; string type = (string)geometry ["type"]; string kind = (string)properties ["kind"]; if (properties.Contains("kind_detail")) { kind = (string)properties ["kind_detail"]; } var id = properties ["id"]; if (idCheck(id, layer) == false && layer.layerType == GOLayer.GOLayerType.Buildings) { continue; } if (layer.useOnly.Length > 0 && !layer.useOnly.Contains(GOEnumUtils.MapzenToKind(kind))) { continue; } if (layer.avoid.Length > 0 && layer.avoid.Contains(GOEnumUtils.MapzenToKind(kind))) { continue; } if (type == "MultiLineString" || (type == "Polygon" && !layer.isPolygon)) { IList lines = new List <object>(); lines = (IList)geometry ["coordinates"]; foreach (IList coordinates in lines) { GOFeature gf = ParseFeatureData(properties, layer); gf.geometry = coordinates; // gf.type = type; gf.layer = layer; gf.parent = parent; gf.properties = properties; gf.ConvertGeometries(); gf.ConvertAttributes(); gf.index = (Int64)features.IndexOf(geo); gf.goFeatureType = GOFeatureType.MultiLine; stack.Add(gf); } } else if (type == "LineString") { IList coordinates = (IList)geometry ["coordinates"]; GOFeature gf = ParseFeatureData(properties, layer); gf.geometry = coordinates; // gf.type = type; gf.layer = layer; gf.parent = parent; gf.properties = properties; gf.ConvertGeometries(); gf.ConvertAttributes(); gf.index = (Int64)features.IndexOf(geo); gf.goFeatureType = GOFeatureType.Line; stack.Add(gf); } else if (type == "Polygon") { List <object> shapes = new List <object>(); shapes = (List <object>)geometry["coordinates"]; IList subject = null; List <object> clips = null; if (shapes.Count == 1) { subject = (List <object>)shapes[0]; } else if (shapes.Count > 1) { subject = (List <object>)shapes[0]; clips = shapes.GetRange(1, shapes.Count - 1); } else { continue; } GOFeature gf = ParseFeatureData(properties, layer); gf.geometry = subject; gf.clips = clips; // gf.type = type; gf.layer = layer; gf.parent = parent; gf.properties = properties; gf.ConvertGeometries(); gf.ConvertAttributes(); gf.index = (Int64)features.IndexOf(geo); gf.goFeatureType = GOFeatureType.Polygon; stack.Add(gf); } if (type == "MultiPolygon") { GameObject multi = new GameObject("MultiPolygon"); multi.transform.parent = parent.transform; IList shapes = new List <object>(); shapes = (IList)geometry["coordinates"]; foreach (List <object> polygon in shapes) { IList subject = null; List <object> clips = null; if (polygon.Count > 0) { subject = (List <object>)polygon[0]; } else if (polygon.Count > 1) { clips = polygon.GetRange(1, polygon.Count - 1); } else { continue; } GOFeature gf = ParseFeatureData(properties, layer); gf.geometry = subject; gf.clips = clips; // gf.type = type; gf.layer = layer; gf.parent = parent; gf.properties = properties; gf.ConvertGeometries(); gf.ConvertAttributes(); gf.index = (Int64)features.IndexOf(geo); gf.goFeatureType = GOFeatureType.MultiPolygon; stack.Add(gf); } } } // if (layer.layerType == GOLayer.GOLayerType.Roads) { // stack = GORoadFeature.MergeRoads (stack); // } // int n = 25; for (int i = 0; i < stack.Count; i += n) { for (int k = 0; k < n; k++) { if (i + k >= stack.Count) { yield return(null); break; } GOFeature r = (GOFeature)stack [i + k]; r.setRenderingOptions(); IEnumerator routine = r.BuildFeature(this, delayedLoad); if (routine != null) { if (Application.isPlaying) { StartCoroutine(routine); } else { GORoutine.start(routine, this); } } } yield return(null); } yield return(null); }