Customer Service | Training | Contact Us
You are here: Home > User Forums > arcgis server forums > Thread Replies

ArcGIS Server Forums

ArcGIS Server Java: Developing applications forum

Buffer WebGeometry   Alex Chen Dec 20, 2007
Re: Buffer WebGeometry   Myoungok Yoo Dec 20, 2007
Re: Buffer WebGeometry   Alex Chen Dec 20, 2007
Re: Buffer WebGeometry   Alex Chen Dec 20, 2007
Re: Buffer WebGeometry   Alex Chen Dec 21, 2007
Re: Buffer WebGeometry   vipul soni Feb 13, 2008
Re: Buffer WebGeometry   Myoungok Yoo Dec 26, 2007
Re: Buffer WebGeometry   Alex Chen Dec 27, 2007
Re: Buffer WebGeometry   Huapeng Chen Jan 17, 2008
Re: Buffer WebGeometry   ruchi yadav Feb 13, 2008
Report Inappropriate Content • Top • Print • Reply    
Subject Buffer WebGeometry 
Author Alex Chen 
Date Dec 20, 2007 
Message Hi all,

I've done a lot of search on the forum for how to buffer a WebGeometry (WebPoint, WebPolyline and WebPolygon) drawn on the web map with a given buffer distance, but with no luck at all. I hope to know which class or interface I need to use.

Any pointer is appreciated. 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Myoungok Yoo 
Date Dec 20, 2007 
Message I took many time same as your consideration.

When I tried to make buffer only use Web ADF API,
on my case i don't.
To make buffer on Web ADF, I had to use SOAPI, specific com.esri.arcgisws.Geometry.

1. assume you know center point and distance.
2. convert WebGeometry(centerPoint) to Geometry(PointN)
3. caculate x,y values on circle using sin, cos.
4. add the web points to WebRing using webRing.add(webpoint)
5. create new WebPolygon has the the webRing objects.


Hopefully it is helpful for you.


if you need some sample code, please let me know.

moyoo.esrikr.co.kr
 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Alex Chen 
Date Dec 20, 2007 
Message Hi Myoungok,

Thanks so much for your quick response!

Actually, I have tried with the same approach you adviced. It worked out and it seemed to work for WebPoint only. How did you manage to make WebPolyline and WebPolygon work? It'd be very nice of you if you can give me a sample.

If we go with programming with ArcObject instead, which way would you recommend, the Geoprocessing Buffer Tool or ITopologicalOperator? This is puzzling me.

Thank you so much. 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Alex Chen 
Date Dec 20, 2007 
Message I have written some codes for buffer an input WebGeometry but it keeps throwing out "AutomationException".

[21/12/07 15:21:46:770 EST] 00000020 SystemErr R AutomationException: 0x80040238

Codes are below. Could anybody help check to find out what is going wrong? Thanks in advance. 
 
public IPolygon bufferFromWebGeometry(WebGeometry webGeom, double bufferDist) {
    AGSLocalMapResource resource = (AGSLocalMapResource) this
        .getContextMgrOnRender().getResources().get("Basemap");

    IServerContext servercontext = resource.getServerContext();

    com.esri.arcgisws.Geometry agsGeom = (com.esri.arcgisws.Geometry) AGSUtil
        .toAGSGeometry(webGeom);

    IGeometry pGeom = (IGeometry) AGSUtil.createArcObjectFromStub(agsGeom, this
        .getServerContext());
    try {

      System.out.println(pGeom.getEnvelope().getXMax() + ","
          + pGeom.getEnvelope().getYMax());

      ITopologicalOperator p, u;

      p = new ITopologicalOperatorProxy(pGeom);
      IPolygon polygon = (IPolygon) p.buffer(bufferDist); // Exception Thrown
      u = new ITopologicalOperatorProxy(polygon);
      IPolygon bufferPolygon = (IPolygon) u.union(polygon);

      return bufferPolygon;
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Alex Chen 
Date Dec 21, 2007 
Message The error message tells "ITopologicalOperator.buffer(Unknown Source)" in the Console.

I am using ArcGIS Server SP 9.2 and IBM WebSphere Application Server. SOS... 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author vipul soni 
Date Feb 13, 2008 
Message use

itopologicaloperator.buffer(0.00025)

0.000025 is the buffer distance..u have to specify some buffer distance here.. 
  Vipul Soni

INDIA 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Myoungok Yoo 
Date Dec 26, 2007 
Message
it does not have to access to ArcObjects.
(We could do it using ITopologicOperator to make buffer)

If you only use Web ADF Command API - WebGeometry such as WebPoint, WebRing and WebPolygon,
you could not draw buffer.

I also experienced same problem.

To resolve the problem, i had to use SOAP Geometry(com.esri.arcgisws).
I am not sure the reason that I use SOAP API.





 
 
WebPolygon webPoly = new WebPolygon();
					
					int increment = 10;
					double x = 0.0;
					double y = 0.0;

//**** 
//maybe this is difference on your code
					PointN clrPnt = new PointN();
					//WebPoint clrPnt = new WebPoint();
					WebRing wr = new WebRing();
					for (int p = 0; p <= 360; p=p+increment) {
						x = centerPnt.getX() + (dist * Math.cos(p*Math.PI/180));
						y = centerPnt.getY() + (dist * Math.sin(p*Math.PI/180));

						clrPnt.setX(x);
						clrPnt.setY(y);
						
						//convert from ws to web point and add to ring
			WebPoint webPnt = (WebPoint)AGSUtil.fromAGSGeometry(clrPnt);
						
						wr.addPoint(webPnt);
					
					}			
					webPoly.addRing(wr);
 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Alex Chen 
Date Dec 27, 2007 
Message Yes, I made the same solution to draw circles. Thanks.

Still looking at any solution to the error above... 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author Huapeng Chen 
Date Jan 17, 2008 
Message Hi there,

I have a simple task to do with arcgis server. I appreciate it if you could give me some feedback or sample codes.

Task:
1. Use point location (x,y) to create a buffer
2. Add the created buffer and some attributes to an existing layer and its attribute table.

Thanks! 
   
Report Inappropriate Content • Top • Print • Reply    
Subject Re: Buffer WebGeometry 
Author ruchi yadav 
Date Feb 13, 2008 
Message Hi I am not able to create a buffer for a point feature.The code I m using selects the points or features that lie within that buffer but it does not create a buffer polygon around that selected point and it also gives me the following error on the console.

java.lang.InternalError: Unable to Stroke shape (null)
at sun.java2d.pipe.LoopPipe.getStrokeSpans(Unknown Source)
at sun.java2d.pipe.LoopPipe.draw(Unknown Source)
at sun.java2d.pipe.ValidatePipe.draw(Unknown Source)
at sun.java2d.SunGraphics2D.draw(Unknown Source)
at com.esri.adf.web.data.display.SimpleLineSymbol.draw(Unknown Source)
at com.esri.adf.web.data.display.SimplePolygonSymbol.draw(Unknown Source)
at com.esri.adf.web.data.display.BaseSymbol.draw(Unknown Source)
at com.esri.adf.web.data.display.WebElementConverter.drawPolygon(Unknown Source)
at com.esri.adf.web.data.g.run(Unknown Source)
at edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:431)
at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:176)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Unknown Source)


Please suggest me what can be done to create a buffer for point feature.
 
 
WebGeometry webGeometry;
		IGeometry buffer;
		IServerContext serverContext;
		IMapServerObjects imapServerObject;
		int featureCounter;
		RectangleToolService rectangleToolService=new RectangleToolService();
		String errorMessage="";
		try {

			WebQuery webQuery=webContext.getWebQuery();
			if(units.compareTo(bundle.getString("kilometers"))==0)
			{
				bufferDistance=bufferDistance*1000;
			}           
			AGSLocalMapResource resource = (AGSLocalMapResource) webContext.getResources().get(aGSLocalMapResourceName);
			serverContext = (IServerContext) resource.getServerContext();			
			imapServerObject=resource.getLocalMapServer();					
			ILayer iLayer = imapServerObject.getLayer(resource.getMapName(),activeLayer);

			IFeatureLayer iFeatureLayer = new IFeatureLayerProxy(iLayer);


			IPolygon polygon =null;
			for(featureCounter=0; featureCounter<selectedFeatures.length; featureCounter++)
			{


				IFeature iFeature = iFeatureLayer.getFeatureClass().getFeature(selectedFeatures[featureCounter]);
				ITopologicalOperator p = new ITopologicalOperatorProxy(iFeature.getShape());
				
				System.out.println("iFeature.getShape():::"+iFeature.getShape().getGeometryType());
				
				
				buffer = p.buffer(bufferDistance); // Assumes a Geographic projection, for simplicity.

				polygon = new IPolygonProxy(buffer);

				polygon.setSpatialReferenceByRef(buffer.getSpatialReference());

				String soapString = com.esri.adf.web.ags.util.AGSUtil.serializeArcObject(polygon,serverContext);
				soapString = soapString.replaceAll("xsi:type=\"soapenc:Array\"", "");
				PolygonN polygonN=(PolygonN)AGSUtil.deserializeStub(soapString,PolygonN.class);	


				SpatialFilter spatialFilter = new SpatialFilter();
				spatialFilter.setSpatialRel(EsriSpatialRelEnum.esriSpatialRelIntersects);
				spatialFilter.setWhereClause("");
				spatialFilter.setSearchOrder(EsriSearchOrder.esriSearchOrderSpatial);
				spatialFilter.setSpatialRelDescription("");
				spatialFilter.setGeometryFieldName("");
				spatialFilter.setFilterGeometry(polygonN);

				errorMessage = rectangleToolService.queryRectangleBuff(webContext,spatialFilter,targetLayer,"Features for id: "+selectedFeatures[featureCounter],aGSLocalMapResourceName,agsMapFunctionalityName);		
				webGeometry=AGSUtil.fromAGSGeometry(polygonN);
				if(webGeometry!=null){
					webQuery.addDisplayGeometry(webGeometry);
				}
				webContext.refresh();
			 }
			
		}