private static TileLayer ProcessTile(FeatureLayer featureLayer, int tileX, int tileY, int zoom, IEnumerable <string> columnNames, int simplificationFactor, int tileSize) { RectangleShape tileBoundingBox = GetTileSphericalMercatorBoundingBox(tileX, tileY, zoom, tileSize); RectangleShape scaledUpBoudingBox = new RectangleShape(tileBoundingBox.GetWellKnownBinary()); scaledUpBoudingBox.ScaleUp(5); featureLayer.Open(); Collection <string> allFeatureIds = featureLayer.FeatureSource.GetFeatureIdsInsideBoundingBox(scaledUpBoudingBox); RectangleInt tileScreenBoundingBox = new RectangleInt() { XMin = -20, YMin = -20, XMax = tileSize + 20, YMax = tileSize + 20 }; TileLayer tileLayer = new TileLayer(); tileLayer.Extent = (uint)tileSize; tileLayer.Version = 2; tileLayer.Name = featureLayer.Name; int IdsCountToExecute = allFeatureIds.Count; int startIndex = 0; while (IdsCountToExecute > 0) { List <string> featureIds = GetSubString(allFeatureIds, startIndex, Math.Min(1000, IdsCountToExecute)); IdsCountToExecute = IdsCountToExecute - featureIds.Count; startIndex = startIndex + featureIds.Count; Collection <Feature> features = GetFeaturesByIds(featureLayer, featureIds, columnNames); foreach (Feature feature in features) { TileFeature tileFeature = GetVectorTileFeature(feature, zoom, tileSize, tileScreenBoundingBox, simplificationFactor, tileBoundingBox); if (tileFeature.Geometry.Count > 0) { tileLayer.Features.Add(tileFeature); } } } tileLayer.FillInTheInternalProperties(); return(tileLayer); }
private void btnGetEnvelope_Click(object sender, RoutedEventArgs e) { ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.Get("Countries02_3857.shp")); worldLayer.Open(); RectangleShape usBoundingBox = worldLayer.QueryTools.GetFeatureById("137", new string[0]).GetBoundingBox(); worldLayer.Close(); InMemoryFeatureLayer boundingBoxLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("BoundingBoxLayer"); if (!boundingBoxLayer.InternalFeatures.Contains("BoundingBox")) { boundingBoxLayer.InternalFeatures.Add("BoundingBox", new Feature(usBoundingBox.GetWellKnownBinary(), "BoundingBox")); } mapView.Overlays["BoundingBoxOverlay"].Refresh(); }
private void btnGetEnvelope_Click(object sender, EventArgs e) { ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp"); worldLayer.Open(); RectangleShape usBoundingBox = worldLayer.QueryTools.GetFeatureById("137", new string[0]).GetBoundingBox(); worldLayer.Close(); InMemoryFeatureLayer boundingBoxLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("BoundingBoxLayer"); if (!boundingBoxLayer.InternalFeatures.Contains("BoundingBox")) { boundingBoxLayer.InternalFeatures.Add("BoundingBox", new Feature(usBoundingBox.GetWellKnownBinary(), "BoundingBox")); } winformsMap1.Refresh(winformsMap1.Overlays["BoundingBoxOverlay"]); }
private void EnvelopeButtonClick(object sender, EventArgs e) { LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; worldLayer.Open(); RectangleShape usBoundingBox = worldLayer.QueryTools.GetFeatureById("137", new string[0]).GetBoundingBox(); worldLayer.Close(); InMemoryFeatureLayer boundingBoxLayer = ((LayerOverlay)androidMap.Overlays["BoundingBoxOverlay"]).Layers["BoundingBoxLayer"] as InMemoryFeatureLayer; if (!boundingBoxLayer.InternalFeatures.Contains("BoundingBox")) { boundingBoxLayer.InternalFeatures.Add("BoundingBox", new Feature(usBoundingBox.GetWellKnownBinary(), "BoundingBox")); } androidMap.Overlays["BoundingBoxOverlay"].Refresh(); }