private void oneshotCallbackToolStripMenuItem_Click(object sender, EventArgs e) { MgGeometryFactory geomFact = new MgGeometryFactory(); mapViewer.DigitizePoint((x, y) => { MgCoordinate coord = geomFact.CreateCoordinateXY(x, y); MgPoint pt = geomFact.CreatePoint(coord); mapViewer.SelectByGeometry(pt, -1, (selection) => { if (selection == null) { MessageBox.Show("No selected features"); return; } else { MgReadOnlyLayerCollection layers = selection.GetLayers(); if (layers != null) { StringBuilder sb = new StringBuilder("Selection summary:"); for (int i = 0; i < layers.GetCount(); i++) { MgLayerBase lyr = layers.GetItem(i); sb.Append(Environment.NewLine + lyr.GetName() + ": " + selection.GetSelectedFeaturesCount(lyr, lyr.GetFeatureClassName())); } MessageBox.Show(sb.ToString()); } else { MessageBox.Show("No selected features"); } } }); }); }
/// <summary>(public) /// replace the content of a marked text within an edit control /// </summary> /// <param name = "ctrl">the control to operate upon </param> /// <param name = "str">text to replace </param> /// <returns>succeed or failed </returns> public static bool MarkedTextSet(MgControlBase ctrl, String str) { if (!ctrl.isTextOrTreeEdit()) { return(false); } MgPoint selection = SelectionGet(ctrl); // return if no text is selected if (selection.x == selection.y) { return(false); } bool successful = true; if (ctrl.isRichEditControl()) { #if !PocketPC Commands.setMarkedTextOnRichEdit(ctrl, ctrl.getDisplayLine(true), str); #endif } else { successful = TextMaskEditor.MarkedTextSet(ctrl, str); } return(successful); }
private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double?scale) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService); MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); MgLayout layout = null; if (useLayout) { MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches); } if (!scale.HasValue) { return(mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion)); } else { MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate(); return(mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion)); } }
public void Execute(IPlatformFactory factory, ITestLogger logger) { var wkt = new MgWktReaderWriter(); MgPoint geom1 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint; MgPoint geom2 = wkt.Read("POINT XY (2.0 2.0)") as MgPoint; MgPoint geom3 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint; MgPointCollection coll = new MgPointCollection(); coll.Add(geom1); coll.Add(geom2); coll.Add(geom3); Assert.AreEqual(3, coll.Count); Assert.IsTrue(geom1.Equals(coll[0])); Assert.IsTrue(coll[0].Equals(coll[2])); Assert.IsFalse(coll[0].Equals(coll[1])); coll[0] = coll[1]; Assert.IsTrue(coll[0].Equals(coll[1])); double x = 0.0; foreach (MgPoint geom in coll) { x += geom.GetCoordinate().GetX(); } Assert.AreEqual(5.0, x); }
public static void AddPointFeature(string FeatureName, MgPropertyCollection featureProps, MgPoint geom, MgFeatureService featureSrvc, MgResourceIdentifier dataSourceId) { MgByteReader geomReader = new MgAgfReaderWriter().Write(geom); MgGeometryProperty geometryProp = new MgGeometryProperty("GEOM", geomReader); featureProps.Add(geometryProp); MgInsertFeatures cmd = new MgInsertFeatures(FeatureName, featureProps); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); commands.Add(cmd); ReleaseReader(featureSrvc.UpdateFeatures(dataSourceId, commands, false)); }
string pointTransformAndWriteZ(string geom, MgMap map) { double[] x = new double[1]; double[] y = new double[1]; double[] z = new double[1]; MgWktReaderWriter wktrwdmr = new MgWktReaderWriter(); MgPoint cntr = wktrwdmr.Read(geom).Centroid; x[0] = cntr.Coordinate.X; y[0] = cntr.Coordinate.Y; z[0] = 0; StringBuilder output = new StringBuilder(); output.Append("<table width=\"100%\" class=\"results\">"); //WGS preko MG API MgCoordinateSystemFactory fact = new MgCoordinateSystemFactory(); string wktFrom = map.GetMapSRS(); string wktTo = "GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]"; MgCoordinateSystem CSSource = fact.Create(wktFrom); MgCoordinateSystem CSTarget = fact.Create(wktTo); MgCoordinateSystemTransform coordTransform = fact.GetTransform(CSSource, CSTarget); MgGeometryFactory geomFact = new MgGeometryFactory(); // GK //samo prvo višino zaenkrat, dokler ni enačbe za Z output.Append(String.Format("<tr><td class='header'><b>Map koordinates:</b></td><td class=\"results\"><table><tr><td><b>Y:</b></td><td>{0}</td></tr><tr><td><b>X:</b></td><td>{1}</td></tr></table></td></tr>", string.Format("{0:0.0}", x[0]), string.Format("{0:0.0}", y[0]))); int i = 0; //transformacija preko MG koordinatnega sistema foreach (double pointX in x) { MgCoordinate coord = geomFact.CreateCoordinateXY(x[i], y[i]); coord = coordTransform.Transform(coord); x[i] = coord.X; y[i] = coord.Y; i++; } double[] xwgs = x; double[] ywgs = y; output.Append(String.Format("<tr><td class='header'><b>WGS84:</b></td><td class=\"results\"><table><tr><td><b>Lon:</b></td><td>{0}</td></tr><tr><td><b>Lat:</b></td><td>{1}</td></tr></table></td></tr>", string.Format("{0:0.000000}", xwgs[0]), string.Format("{0:0.000000}", ywgs[0]))); output.Append("</table>"); return(output.ToString()); }
/// <summary> /// return the selection on the control /// </summary> /// <param name = "ctrl"> </param> /// <returns> </returns> public static MgPoint SelectionGet(MgControlBase ctrl) { var point = new MgPoint(0, 0); if (ctrl != null && ctrl.isTextOrTreeEdit()) { Commands.selectionGet(ctrl, ctrl.getDisplayLine(true), point); } return(point); }
private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { MgMapViewerProvider provider = _viewer.GetProvider(); MgSelectionBase selection = _viewer.GetSelection(); MgMapBase map = _viewer.GetMap(); MgPoint pt = map.ViewCenter; MgCoordinate coord = pt.Coordinate; float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; float yPos = topMargin; float pageHeight = e.MarginBounds.Height; //Write title var titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, GraphicsUnit.Point); var sizeTitle = e.Graphics.MeasureString(txtTitle.Text, titleFont); e.Graphics.DrawString(txtTitle.Text, titleFont, Brushes.Black, new PointF(leftMargin, yPos)); yPos += (sizeTitle.Height * 1.1f); var scaleFont = SystemFonts.CaptionFont; var scaleStr = string.Format("{0} 1 : {1}", Strings.TextScale, _viewer.GetMap().ViewScale); //NOXLATE var sizeScale = e.Graphics.MeasureString(scaleStr, scaleFont); //Scale to fit within this page var imgHeight = (int)(pageHeight - (sizeTitle.Height * 1.1f) - (sizeScale.Height * 1.1f)); var imgWidth = e.MarginBounds.Width; using (var state = provider.CreateTransientState()) { var tempState = new MgMapDisplayParameters(coord.X, coord.Y, map.ViewScale, imgWidth, imgHeight, (int)numDPI.Value); state.PushState(tempState); MgByteReader br = provider.RenderMap(selection, "PNG"); //NOXLATE using (MgReadOnlyStream stream = new MgReadOnlyStream(br)) { Image img = Image.FromStream(stream); e.Graphics.DrawImage(img, leftMargin, yPos, imgWidth, imgHeight); img.Dispose(); } } yPos += imgHeight; //Render scale if (chkScale.Checked) { e.Graphics.DrawString(scaleStr, scaleFont, Brushes.Black, new PointF(leftMargin, yPos)); } e.HasMorePages = false; }
public static string MgPointToString(MgPoint pt) { try { var coord = pt.GetCoordinate(); return(string.Format(CultureInfo.InvariantCulture, "({0}:{1})", coord.GetX(), coord.GetY())); } catch (MgException ex) { throw new UnitTestException(string.Format("Exception from MapGuide:\n{0}", ex.GetDetails())); } }
public MgMultiPoint CreateMultiPoint() { MgCoordinate coord1 = factory.CreateCoordinateXYZ(1.0, 2.0, 3.0); MgPoint point1 = factory.CreatePoint(coord1); MgCoordinate coord2 = factory.CreateCoordinateXYZ(4.0, 5.0, 6.0); MgPoint point2 = factory.CreatePoint(coord2); MgCoordinate coord3 = factory.CreateCoordinateXYZ(7.0, 8.0, 9.0); MgPoint point3 = factory.CreatePoint(coord3); MgPointCollection pnts = new MgPointCollection(); pnts.Add(point1); pnts.Add(point2); pnts.Add(point3); return(factory.CreateMultiPoint(pnts)); }
// GET: DwfPlot public ActionResult Index(MapGuideViewerInputModel input) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; DwfPlotViewModel vm = new DwfPlotViewModel() { MapName = input.MapName, Session = input.Session, Scale = map.GetViewScale(), X = coord.X, Y = coord.Y }; return(View(vm)); }
private void btnRenderMap2_Click(object sender, EventArgs e) { //Note we're casting to mg-desktop specific subclasses as this is what mg-desktop rendering APIs expect MgdMap map = (MgdMap)_viewer.GetMap(); MgdSelection selection = (MgdSelection)_viewer.GetSelection(); MgMapViewerProvider provider = _viewer.GetProvider(); MgdRenderingService renderSvc = (MgdRenderingService)provider.CreateService(MgServiceType.RenderingService); MgPoint centerPt = map.ViewCenter; MgCoordinate centerCoord = centerPt.Coordinate; //MgdTransientMapState is a helper class which lets us apply transient state to a map, which is automatically //undone on disposal. This is how we can render custom views of a map with specific display parameters without //permanently changing the display parameters used by the map viewer using (MgTransientMapState tempState = provider.CreateTransientState(map)) { MgMapDisplayParameters state = new MgMapDisplayParameters(centerCoord.X, centerCoord.Y, 5000, 1024, 768, 96); tempState.PushState(state); MgByteReader br = renderSvc.RenderMap(map, selection, "PNG"); using (SaveFileDialog save = new SaveFileDialog()) { save.Filter = "Portable Network Graphics (*.png)|*.png"; if (save.ShowDialog() == DialogResult.OK) { //MgReadOnlyStream is a stream adapter class that provides a .net stream //interface to the MgByteReader, allowing MgByteReader objects to be used //anywhere a System.IO.Stream is expected. using (MgReadOnlyStream stream = new MgReadOnlyStream(br)) { Image img = Image.FromStream(stream); img.Save(save.FileName); MessageBox.Show("Image saved to: " + save.FileName); } } br.Dispose(); } } }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgGeometryFactory gf = new MgGeometryFactory(); MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0); MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10); MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10); MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0); MgPoint mgpt1 = gf.CreatePoint(pt1); MgPoint mgpt2 = gf.CreatePoint(pt2); MgPoint mgpt3 = gf.CreatePoint(pt3); MgPoint mgpt4 = gf.CreatePoint(pt4); MgPointCollection points = new MgPointCollection(); points.Add(mgpt1); points.Add(mgpt2); points.Add(mgpt3); points.Add(mgpt4); MgMultiPoint mp = gf.CreateMultiPoint(points); Assert.AreEqual(4, mp.Count); Assert.AreEqual(MgGeometryType.MultiPoint, mp.GeometryType); Assert.AreEqual(0, mp.Dimension); }
public void LoadResults(MgLayerBase layer, MgFeatureQueryOptions query) { MgClassDefinition clsDef = layer.GetClassDefinition(); MgPropertyDefinitionCollection idProps = clsDef.GetIdentityProperties(); MgPropertyDefinition idProp = idProps[0]; string idPropName = idProp.Name; string geomName = layer.FeatureGeometryName; MgFeatureReader reader = layer.SelectFeatures(query); MgAgfReaderWriter agfRw = new MgAgfReaderWriter(); try { while (reader.ReadNext()) { var res = new ParcelFeatureModel(); res.ID = reader.GetInt32(idPropName); res.Owner = reader.IsNull("RNAME") ? "(unknown)" : reader.GetString("RNAME"); res.Address = reader.IsNull("RPROPAD") ? "(unknown)" : reader.GetString("RPROPAD"); if (!reader.IsNull(geomName)) { MgByteReader agf = reader.GetGeometry(geomName); MgGeometry geom = agfRw.Read(agf); MgPoint center = geom.Centroid; MgCoordinate coord = center.Coordinate; res.X = coord.X; res.Y = coord.Y; } this.Results.Add(res); } } finally { reader.Close(); } }
/// <summary>(public) /// retrieve the currently selected text /// </summary> /// <param name = "ctrl">the control which is assumed to contain the selected text </param> public static String MarkedTextGet(MgControlBase ctrl) { String markedText = null; if (ctrl.isTextOrTreeEdit()) { // get the selected boundary MgPoint selection = SelectionGet(ctrl); // is there any selected text ? if (selection.x != selection.y) { // get the text from the ctrl and the marked text. String text = GetCtrlVal(ctrl); if (ctrl.isRichEditControl()) { text = StrUtil.GetPlainTextfromRtf(text); } markedText = text.Substring(selection.x, (selection.y) - (selection.x)); } } return(markedText); }
public MgPointF(MgPoint point) { this.x = point.x; this.y = point.y; }
public override void Execute(IPlatformFactory factory, ITestLogger logger) { //For a map definition that links to a default provider tile set and both have the same coordinate //system, it should be using the map definition's extents and we should not have null extents or view //center MgCoordinateSystemFactory csFactory = new MgCoordinateSystemFactory(); string csWkt = csFactory.ConvertCoordinateSystemCodeToWkt("LL84"); MgResourceService resSvc = (MgResourceService)factory.CreateService(MgServiceType.ResourceService); var root = "../../TestData/TileService/"; LoadResource(resSvc, "Library://UnitTests/Data/RoadCenterLines.FeatureSource", root + "UT_RoadCenterLines.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/RoadCenterLines.FeatureSource", "UT_RoadCenterLines.sdf", MgResourceDataType.File, root + "UT_RoadCenterLines.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/RoadCenterLines.LayerDefinition", root + "UT_RoadCenterLines.ldf"); LoadResource(resSvc, "Library://UnitTests/Data/VotingDistricts.FeatureSource", root + "UT_VotingDistricts.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/VotingDistricts.FeatureSource", "UT_VotingDistricts.sdf", MgResourceDataType.File, root + "UT_VotingDistricts.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/VotingDistricts.LayerDefinition", root + "UT_VotingDistricts.ldf"); LoadResource(resSvc, "Library://UnitTests/Data/Parcels.FeatureSource", root + "UT_Parcels.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/Parcels.FeatureSource", "UT_Parcels.sdf", MgResourceDataType.File, root + "UT_Parcels.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/Parcels.LayerDefinition", root + "UT_Parcels.ldf"); string tsd = Encoding.UTF8.GetString(Properties.Resources.UT_BaseMapTileSet); tsd = string.Format(tsd, csWkt, -87.5, 43.5, -86.5, 44.5); byte[] tsdBytes = Encoding.UTF8.GetBytes(tsd); MgByteSource sourceTSD = new MgByteSource(tsdBytes, tsdBytes.Length); MgByteReader contentTSD = sourceTSD.GetReader(); MgResourceIdentifier resTSD = new MgResourceIdentifier("Library://UnitTests/TileSets/Test.TileSetDefinition"); resSvc.SetResource(resTSD, contentTSD, null); string mdf = Encoding.UTF8.GetString(Properties.Resources.UT_LinkedTileSet); mdf = string.Format(mdf, csWkt, -87.0, 43.0, -86.0, 44.0, resTSD.ToString()); byte[] mdfBytes = Encoding.UTF8.GetBytes(mdf); MgByteSource sourceMDF = new MgByteSource(mdfBytes, mdfBytes.Length); MgByteReader contentMDF = sourceMDF.GetReader(); MgResourceIdentifier resMDF = new MgResourceIdentifier("Library://UnitTests/Maps/LinkedTileSet.MapDefinition"); resSvc.SetResource(resMDF, contentMDF, null); MgMapBase map = factory.CreateMap(resMDF); MgEnvelope extent = map.GetMapExtent(); Assert.IsNotNull(extent); Assert.IsNotNull(map.MapExtent); MgPoint center = map.GetViewCenter(); Assert.IsNotNull(center); Assert.IsNotNull(map.ViewCenter); MgCoordinate ll = extent.GetLowerLeftCoordinate(); MgCoordinate ur = extent.GetUpperRightCoordinate(); Assert.IsNotNull(ll); Assert.IsNotNull(ur); Assert.AreEqual(-87.0, ll.X); Assert.AreEqual(43.0, ll.Y); Assert.AreEqual(-86.0, ur.X); Assert.AreEqual(44.0, ur.Y); }
private void btnFindFeaturesInBuffer_Click(object sender, EventArgs e) { MgSelectionBase selection = _viewer.GetSelection(); MgReadOnlyLayerCollection selectedLayers = selection.GetLayers(); if (selectedLayers == null) { MessageBox.Show("Select a parcel"); return; } MgLayerBase parcels = null; for (int i = 0; i < selectedLayers.GetCount(); i++) { MgLayerBase layer = selectedLayers.GetItem(i); if (layer.Name == "Parcels") { parcels = layer; break; } } if (parcels == null) { MessageBox.Show("Select a parcel"); return; } int bufferRingSize = 500; // measured in metres // Set up some objects for coordinate conversion MgMapBase map = _viewer.GetMap(); MgLayerCollection mapLayers = map.GetLayers(); MgMapViewerProvider provider = _viewer.GetProvider(); MgResourceService resourceService = (MgResourceService)provider.CreateService(MgServiceType.ResourceService); //Casting to MgdFeatureService because we want to use convenience APIs MgFeatureService featureService = (MgdFeatureService)provider.CreateService(MgServiceType.FeatureService); string sessionId = Guid.NewGuid().ToString(); String mapWktSrs = map.GetMapSRS(); MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter(); MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter(); MgCoordinateSystemFactory coordinateSystemFactory = new MgCoordinateSystemFactory(); MgCoordinateSystem srs = coordinateSystemFactory.Create(mapWktSrs); MgMeasure srsMeasure = srs.GetMeasure(); // Check for a buffer layer. If it exists, delete // the current features. // If it does not exist, create a feature source and // a layer to hold the buffer. BufferHelper helper = new BufferHelper(); MgdLayer bufferLayer = null; int layerIndex = map.GetLayers().IndexOf("Buffer"); if (layerIndex < 0) { // The layer does not exist and must be created. MgResourceIdentifier bufferFeatureResId = new MgResourceIdentifier("Session:" + sessionId + "//Buffer.FeatureSource"); helper.CreateBufferFeatureSource(featureService, mapWktSrs, bufferFeatureResId); bufferLayer = helper.CreateBufferLayer(resourceService, bufferFeatureResId, sessionId); map.GetLayers().Insert(0, bufferLayer); } else { bufferLayer = (MgdLayer)map.GetLayers().GetItem(layerIndex); bufferLayer.DeleteFeatures("ID like '%'"); } // Check for a parcel marker layer. If it exists, delete // the current features. // If it does not exist, create a feature source and // a layer to hold the parcel markers. MgdLayer parcelMarkerLayer = null; layerIndex = map.GetLayers().IndexOf("ParcelMarker"); if (layerIndex < 0) { MgResourceIdentifier parcelFeatureResId = new MgResourceIdentifier("Session:" + sessionId + "//ParcelMarker.FeatureSource"); helper.CreateParcelMarkerFeatureSource(featureService, mapWktSrs, parcelFeatureResId); parcelMarkerLayer = helper.CreateParcelMarkerLayer(resourceService, parcelFeatureResId, sessionId); map.GetLayers().Insert(0, parcelMarkerLayer); } else { parcelMarkerLayer = (MgdLayer)map.GetLayers().GetItem(layerIndex); parcelMarkerLayer.DeleteFeatures("ID like '%'"); } // Check each layer in the selection. for (int i = 0; i < selectedLayers.GetCount(); i++) { // Only check selected features in the Parcels layer. MgdLayer layer = (MgdLayer)selectedLayers.GetItem(i); if (layer.GetName() == "Parcels") { string geomName = layer.GetFeatureGeometryName(); System.Diagnostics.Trace.TraceInformation("Marking all parcels inside the buffer that are of type 'MFG'"); MgFeatureReader featureReader = selection.GetSelectedFeatures(layer, layer.GetFeatureClassName(), false); // Process each item in the MgFeatureReader. Get the // geometries from all the selected features and // merge them into a single geometry. MgGeometryCollection inputGeometries = new MgGeometryCollection(); while (featureReader.ReadNext()) { MgByteReader featureGeometryData = featureReader.GetGeometry(geomName); MgGeometry featureGeometry = agfReaderWriter.Read(featureGeometryData); inputGeometries.Add(featureGeometry); } MgGeometryFactory geometryFactory = new MgGeometryFactory(); MgGeometry mergedGeometries = geometryFactory.CreateMultiGeometry(inputGeometries); // Create a buffer from the merged geometries double bufferDist = srs.ConvertMetersToCoordinateSystemUnits(bufferRingSize); MgGeometry bufferGeometry = mergedGeometries.Buffer(bufferDist, srsMeasure); // Create a filter to select parcels within the buffer. Combine // a basic filter and a spatial filter to select all parcels // within the buffer that are of type "MFG". MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions(); queryOptions.SetFilter("RTYPE = 'MFG'"); queryOptions.SetSpatialFilter(geomName, bufferGeometry, MgFeatureSpatialOperations.Inside); featureReader = layer.SelectFeatures(queryOptions); // Get the features from the feature source, // determine the centroid of each selected feature, and // add a point to the ParcelMarker layer to mark the // centroid. // Collect all the points into an MgFeatureCommandCollection, // so they can all be added in one operation. MgFeatureCommandCollection parcelMarkerCommands = new MgFeatureCommandCollection(); int inserted = 0; while (featureReader.ReadNext()) { MgByteReader byteReader = featureReader.GetGeometry(geomName); MgGeometry geometry = agfReaderWriter.Read(byteReader); MgPoint point = geometry.GetCentroid(); // Create an insert command for this parcel. MgPropertyCollection properties = new MgPropertyCollection(); properties.Add(new MgGeometryProperty("ParcelLocation", agfReaderWriter.Write(point))); //parcelMarkerCommands.Add(new MgInsertFeatures("ParcelMarkerClass", properties)); MgFeatureReader fr = parcelMarkerLayer.InsertFeatures(properties); fr.Close(); inserted++; } featureReader.Close(); if (inserted == 0) { MessageBox.Show("No parcels within the buffer area match."); return; } // Create a feature in the buffer feature source to show the area covered by the buffer. MgPropertyCollection props = new MgPropertyCollection(); props.Add(new MgGeometryProperty("BufferGeometry", agfReaderWriter.Write(bufferGeometry))); bufferLayer.InsertFeatures(props); // Ensure that the buffer layer is visible and in the legend. bufferLayer.SetVisible(true); bufferLayer.ForceRefresh(); bufferLayer.SetDisplayInLegend(true); parcelMarkerLayer.SetVisible(true); parcelMarkerLayer.ForceRefresh(); MessageBox.Show("Done"); _viewer.RefreshMap(); IMapLegend legend = Shell.Instance.Legend; if (legend != null) { legend.RefreshLegend(); } } } }