public override GOFeature EditLabelData(GOFeature goFeature) { goFeature.name = (string)goFeature.properties ["name"]; goFeature.kind = GOEnumUtils.MapzenToKind((string)goFeature.properties ["kind"]); if (goFeature.properties.Contains("kind_detail")) //Mapzen { goFeature.kind = GOEnumUtils.MapzenToKind((string)goFeature.properties ["kind_detail"]); } Int64 sort = 0; if (goFeature.properties.Contains("sort_rank")) { sort = Convert.ToInt64(goFeature.properties ["sort_rank"]); } else if (goFeature.properties.Contains("sort_key")) { sort = Convert.ToInt64(goFeature.properties ["sort_key"]); } goFeature.y = sort / 1000.0f; goFeature.sort = sort; 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 GOFeature ParseFeatureData(IDictionary properties, GOLayer layer) { GOFeature goFeature; if (layer.layerType == GOLayer.GOLayerType.Roads) { goFeature = new GORoadFeature(); goFeature.kind = GOEnumUtils.MapzenToKind((string)properties ["kind"]); if (properties.Contains("kind_detail")) //Mapzen { goFeature.detail = (string)properties ["kind_detail"]; } ((GORoadFeature)goFeature).isBridge = properties.Contains("is_bridge") && properties ["is_bridge"].ToString() == "True"; ((GORoadFeature)goFeature).isTunnel = properties.Contains("is_tunnel") && properties ["is_tunnel"].ToString() == "True"; ((GORoadFeature)goFeature).isLink = properties.Contains("is_link") && properties ["is_link"].ToString() == "True"; } else { goFeature = new GOFeature(); goFeature.kind = GOEnumUtils.MapzenToKind((string)properties ["kind"]); if (properties.Contains("kind_detail")) //Mapzen { goFeature.kind = GOEnumUtils.MapzenToKind((string)properties ["kind_detail"]); } } goFeature.name = (string)properties ["name"]; Int64 sort = 0; if (properties.Contains("sort_rank")) { sort = (Int64)properties ["sort_rank"]; } else if (properties.Contains("sort_key")) { sort = (Int64)properties ["sort_key"]; } goFeature.y = sort / 1000.0f; goFeature.sort = sort; goFeature.height = layer.defaultRendering.polygonHeight; if (layer.useRealHeight && properties.Contains("height")) { double h = Convert.ToDouble(properties["height"]); goFeature.height = (float)h; } if (layer.useRealHeight && properties.Contains("min_height")) { double hm = Convert.ToDouble(properties["min_height"]); goFeature.y = (float)hm; if (goFeature.height >= hm) { goFeature.y = (float)hm; goFeature.height = (float)goFeature.height - (float)hm; } } return(goFeature); }
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 = GOFeature.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 = GOFeature.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 = GOFeature.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 = GOFeature.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]; 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); }