laptop and a wrench

Bug

ArcGIS_SelectBufferTool_VBNet developer sample is not working with esriSRProjCS_NAD1983_10TM_AEP_Resource spatial reference.

Last Published: August 25, 2014 No Product Found
Bug ID Number NIM009400
SubmittedMay 31, 2007
Last ModifiedJune 5, 2024
Applies toNo Product Found
Version found9.2
Program languageVB.Net
StatusWill Not Be Addressed

Additional Information

We apologize that we were unable to address this issue within the current product support cycle. If the issue continues to affect your work in a supported release, please contact Technical Support.

Workaround

#1. In the App_Code > CustomTools.vb > BufferToolNew::ServerAction routine, comment out the following code and the sample starts working.'projpoly.SpatialReference = srgeo#2. Alternate code for the buffer tool cuts out a lot of the spatial reference code that was there before and instead sets the "mappoly" variable's spatial reference to that of the map:Public Sub ServerAction(ByVal args As ToolEventArgs) Implements IMapServerToolAction.ServerAction Dim resource_index As Integer = 2 Dim mapctrl As ESRI.ArcGIS.ADF.Web.UI.WebControls.Map = CType(args.Control, ESRI.ArcGIS.ADF.Web.UI.WebControls.Map) Dim sourcelayername As String = CStr(mapctrl.Page.Session("SourceLayer")) Dim webSpatial As ESRI.ArcGIS.ADF.Web.SpatialReference.SpatialReference = mapctrl.SpatialReference Dim webSpatialinfo As ESRI.ArcGIS.ADF.Web.SpatialReference.DefinitionSpatialReferenceInfo = webSpatial.CoordinateSystem Dim mf As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = CType(mapctrl.GetFunctionality(resource_index), ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality) Dim gisresource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = mf.Resource Dim rectargs As RectangleEventArgs = CType(args, RectangleEventArgs) Dim myrect As System.Drawing.Rectangle = rectargs.ScreenExtent Dim minpnt As ESRI.ArcGIS.ADF.Web.Geometry.Point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Left, myrect.Bottom, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height) Dim maxpnt As ESRI.ArcGIS.ADF.Web.Geometry.Point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Right, myrect.Top, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height) Dim mappoly As ESRI.ArcGIS.ADF.Web.Geometry.Envelope = New ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minpnt, maxpnt) Dim supported As Boolean = gisresource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)) If supported Then Dim qfunc As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = CType(gisresource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality) Dim lids As String() Dim lnames As String() qfunc.GetQueryableLayers(Nothing, lids, lnames) Dim layer_index As Integer = 0 Dim i As Integer = 0 Do While i < lnames.Length If lnames(i) = sourcelayername Then If TypeOf lids(i) Is String Then If (Not Integer.TryParse(CStr(lids(i)), layer_index)) Then layer_index = i End If Else layer_index = i End If Exit Do End If i += 1 Loop If TypeOf qfunc.Resource Is ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal Then Dim ags_mf As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality = CType(mf, ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality) Dim ags_mr As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal = CType(qfunc.Resource, ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal) Dim sc As ESRI.ArcGIS.Server.IServerContext = ags_mr.ServerContextInfo.ServerContext Dim mapdescription As ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapdescription = ags_mf.MapDescription Dim pc As ESRI.ArcGIS.ADF.Web.Geometry.PointCollection = New ESRI.ArcGIS.ADF.Web.Geometry.PointCollection() pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Left, myrect.Bottom, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height)) pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Right, myrect.Bottom, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height)) pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Right, myrect.Top, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height)) pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Left, myrect.Top, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height)) Dim ring As ESRI.ArcGIS.ADF.Web.Geometry.Ring = New ESRI.ArcGIS.ADF.Web.Geometry.Ring() ring.Points = pc Dim rings As ESRI.ArcGIS.ADF.Web.Geometry.RingCollection = New ESRI.ArcGIS.ADF.Web.Geometry.RingCollection() rings.Add(ring) Dim mappoly2 As ESRI.ArcGIS.ADF.Web.Geometry.Polygon = New ESRI.ArcGIS.ADF.Web.Geometry.Polygon() mappoly2.Rings = rings mappoly2.SpatialReference = mapctrl.SpatialReference '' Set an input coordinate system 'Dim srgeo As ESRI.ArcGIS.Geometry.ISpatialReference 'Dim srenv As ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment = CType(sc.CreateObject("esriGeometry.SpatialReferenceEnvironment"), ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment) 'Dim igcs As ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem = srenv.CreateGeographicCoordinateSystem(4269) 'esriSRGeoCS_NAD1983 ''Dim igcs As ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem = srenv.CreateGeographicCoordinateSystem(4326) 'esriSRGeoCS_WGS1984 'srgeo = CType(igcs, ESRI.ArcGIS.Geometry.ISpatialReference) 'srgeo.SetFalseOriginAndUnits(-180, -90, 1000000) '' Set an output coordinate system 'Dim srproj As ESRI.ArcGIS.Geometry.ISpatialReference 'Dim ipcs As ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem = srenv.CreateProjectedCoordinateSystem(102185) 'esriSRProjCS_NAD1983_10TM_AEP_Resource ''Dim ipcs As ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem = srenv.CreateProjectedCoordinateSystem(102008) 'srproj = CType(ipcs, ESRI.ArcGIS.Geometry.ISpatialReference) '' Project the user polygon Dim projpoly As ESRI.ArcGIS.Geometry.IPolygon = CType(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(mappoly2, sc), ESRI.ArcGIS.Geometry.IPolygon) 'projpoly.SpatialReference = srgeo 'projpoly.Project(srproj) ' Buffer the user polygon, define distance in projected units Dim topop As ESRI.ArcGIS.Geometry.ITopologicalOperator4 = CType(projpoly, ESRI.ArcGIS.Geometry.ITopologicalOperator4) Dim strbd As String = CStr(mapctrl.Page.Session("BufferDistance")) Dim bufferdistance As Double If (Not Double.TryParse(strbd, bufferdistance)) Then bufferdistance = 0.0 End If Dim bufferunits As String = CStr(mapctrl.Page.Session("BufferUnits")) Dim ags_bufferunits As ESRI.ArcGIS.esriSystem.esriUnits ags_bufferunits = CType(System.Enum.Parse(GetType(ESRI.ArcGIS.esriSystem.esriUnits), "esri" & bufferunits, True), ESRI.ArcGIS.esriSystem.esriUnits) Dim iuc As ESRI.ArcGIS.esriSystem.IUnitConverter = CType(sc.CreateObject("esriSystem.UnitConverter"), ESRI.ArcGIS.esriSystem.IUnitConverter) Dim converted_bufferdistance As Double = iuc.ConvertUnits(bufferdistance, ags_bufferunits, ESRI.ArcGIS.esriSystem.esriUnits.esriMeters) Dim bufferpolygon As ESRI.ArcGIS.Geometry.IPolygon = CType(topop.Buffer(converted_bufferdistance), ESRI.ArcGIS.Geometry.IPolygon) ' Create polygon element to display projected buffer geometry Dim buffer_polyn As PolygonN = CType(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ComObjectToValueObject(bufferpolygon, sc, GetType(PolygonN)), PolygonN) Dim rgb1 As ESRI.ArcGIS.ADF.ArcGISServer.RgbColor = New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor() rgb1.Red = 255 rgb1.Green = 0 rgb1.Blue = 0 rgb1.AlphaValue = 255 Dim sfs1 As ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol = New ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol() sfs1.Style = esriSimpleFillStyle.esriSFSForwardDiagonal sfs1.Color = rgb1 Dim polyelement1 As ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement = New ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement() polyelement1.Symbol = sfs1 polyelement1.Polygon = buffer_polyn ' Create polygon element to display user rectangle Dim envelopen As PolygonN = CType(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ComObjectToValueObject(projpoly, sc, GetType(PolygonN)), PolygonN) Dim rgb2 As ESRI.ArcGIS.ADF.ArcGISServer.RgbColor = New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor() rgb2.Red = 0 rgb2.Green = 250 rgb2.Blue = 0 rgb2.AlphaValue = 255 Dim sfs2 As ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol = New ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol() sfs2.Style = ESRI.ArcGIS.ADF.ArcGISServer.esriSimpleFillStyle.esriSFSSolid sfs2.Color = rgb2 Dim sls2 As ESRI.ArcGIS.ADF.ArcGISServer.SimpleLineSymbol = New SimpleLineSymbol() sls2.Color = rgb1 sls2.Style = esriSimpleLineStyle.esriSLSSolid sls2.Width = 4 sfs2.Outline = sls2 Dim polyelement2 As ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement = New ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement() polyelement2.Symbol = sfs2 polyelement2.Polygon = envelopen ' Draw graphic elements on map generated by map server Dim ges As GraphicElement() = New GraphicElement(1) {} ges(0) = polyelement1 ges(1) = polyelement2 mapdescription.CustomGraphics = ges ' Show features selected by buffer Dim layerdescs As LayerDescription() = mapdescription.LayerDescriptions Dim mli As MapLayerInfo() = ags_mr.MapServerInfo.MapLayerInfos Dim featureLayer As LayerDescription = layerdescs(layer_index) If featureLayer Is Nothing Then ' throw exception because feature layer is not valid Throw New Exception("featurelayer null") Else Dim sf As SpatialFilter = New SpatialFilter() sf.FilterGeometry = buffer_polyn sf.GeometryFieldName = "SHAPE" sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects Dim msdp As MapServerProxy = ags_mr.MapServerProxy Dim irgbc As RgbColor = New RgbColor() irgbc.Red = 250 irgbc.Green = 250 irgbc.Blue = 0 irgbc.AlphaValue = 255 featureLayer.SelectionColor = irgbc Dim ifid As FIDSet = msdp.QueryFeatureIDs(mapdescription.Name, featureLayer.LayerID, sf) featureLayer.SelectionFeatures = ifid.FIDArray End If mapctrl.Refresh() End If End If End Sub

Steps to Reproduce

Bug ID: NIM009400

Software:

  • No Product Found

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options