POST
|
Change your zoom level with the code you have. Does it catch the feature you want to identify? It does!
envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7);
In the above, me.getX() and me.getY() are screen coordinates. They are independent of zoom. The .toMapPoint(x,y) function changes those screen coordinates to geographic coordinates. To answer your other question, I haven't tried geographic coordinates or any projection other than NAD83 State Plane Ohio South. I THINK (operative word!) that it would still work the same way. Andrew
... View more
08-14-2012
05:04 AM
|
0
|
0
|
261
|
POST
|
Thanks! That's what I needed. Based on some tests I did, it appears that if you pass it a point object, you have to have the EXACT POINT or it will fail. Passing it an envelope worked. For the sake of anyone finding this later on, here is the code I'm using: for(int x=0;x<focusMap.getLayerCount();x++){
if(focusMap.getLayer(x).getName().equals("Origin Locations")){
FeatureLayer featLayer=(FeatureLayer) focusMap.getLayer(x);
IIdentify ident=featLayer;
IEnvelope envelope = new Envelope();
IPoint envLL=new Point();
IPoint envUR=new Point();
envLL=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()-5, me.getY()+7);
envUR=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX()+5, me.getY()-7);
envelope.setLowerLeft(envLL);
envelope.setUpperRight(envUR);
IArray result=ident.identify(envelope);
if(result!=null){
for(int i=0;i<result.getCount();i++){
System.out.println(result.getElement(i).toString());
}
}
}
} I based the envelope on the screen coordinates and converted them to geographic coordinates for the points for the envelope upper-right and lower-left corners of the envelope. This hopefully will serve me well at different zoom levels. The X +/- 5 and Y+/- 7 works for me, but others may want to run a few tests to see if their mileage varies. Andrew
... View more
08-13-2012
12:54 PM
|
0
|
0
|
261
|
POST
|
I am trying to identify the feature a user clicks on. This would be similar to the identify tool, but instead of showing a window, I want to take some of the feature attributes and put them into another table. The problem I'm having is that every way I try to identify the feature that was clicked on, I get a null result. The code I'm using is below: for(int x=0;x<focusMap.getLayerCount();x++){ if(focusMap.getLayer(x).getName().equals("Origin Locations")){ FeatureLayer featLayer=(FeatureLayer) focusMap.getLayer(x); IIdentify ident=featLayer; IPoint point=new Point(); point=activeView.getScreenDisplay().getDisplayTransformation().toMapPoint(me.getX(), me.getY()); /* * The point object has the correct geographic coordinates at this point, so I'm thinking it is not the issue (and at * one point, I thought that was the issue because I was passing screen coordinates to the identify commands * below). */ IArray result=ident.identify(point); IArray result2=featLayer.identify(point,null); IArray result3=featLayer.identify(point); /* * The result, result2, and result3 objects (above) are all null here. I've tried passing an IGeometry object to these * commands as well, and that was to no avail. */ if(result!=null){ for(int i=0;i<result.getCount();i++){ System.out.println(result.getElement(i).toString()); } } } } If anyone can get me pointed in the right direction here, I would appreciate it! Andrew Rohne OKI Regional Council
... View more
08-13-2012
07:03 AM
|
0
|
6
|
824
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|