View Full Version : Select Parcel onDigitizePoint
sdaniel.3467
2005-05-17, 12:50 PM
I need to place/create a point and select the parcel that the point falls on. I have the correct code for digitizing the point. I've tried a select radius on the parcels with the coordinate digitized but the parcel does not get selected. Here's the code so far:
var myMap=getMap();
myMap.setAutoRefresh(false);
myMap.setSelectionMode('Intersection');
myMap.selectRadius('Parcel',point.getX(),point.getY(),1,'Feet');
var mySelection=myMap.getSelection().getMapObjectsEx('Parcel');
var key=mySelection.Item(0).getKey();
myMap.setAutoRefresh(true);
Any thoughts?
MHultgren
2005-05-17, 02:20 PM
Maybe if you changed the Selection mode to Nearest?
sdaniel.3467
2005-05-18, 12:29 PM
What do you mean Nearest? Aren't the only two choices Intersection or Centroid?
sdaniel.3467
2005-05-18, 02:05 PM
Received this idea from Autodesk Newsgroup:
Selecting parcel by polygon, works great!!
var myMap=getMap();
myMap.setAutoRefresh(false);
// get the coordinates of the digitized point
var xCoord = point.getX();
var yCoord = point.getY();
// initialize a collection to store points in memory
var tempCollection = myMap.createObject("MGCollection");
// initialize 4 points to create a polygon
var tempPoint1 = myMap.createObject("MGPoint");
var tempPoint2 = myMap.createObject("MGPoint");
var tempPoint3 = myMap.createObject("MGPoint");
var tempPoint4 = myMap.createObject("MGPoint");
// step 2: create a polygon in memory around the digitized point
// create point
tempPoint1.X = xCoord
tempPoint1.Y = yCoord + 0.000001;
// add point to collection
tempCollection.Add(tempPoint1);
// point 2
tempPoint2.X = xCoord + 0.000001;
tempPoint2.Y = yCoord;
tempCollection.Add(tempPoint2);
// point 3
tempPoint3.X = xCoord;
tempPoint3.Y = yCoord - 0.000001;
tempCollection.Add(tempPoint3);
// point 4
tempPoint4.X = xCoord - 0.000001;
tempPoint4.Y = yCoord;
tempCollection.Add(tempPoint4);
// to close the polygon, add point 1 once more to the collection
tempCollection.Add(tempPoint1);
// step 3: select objects
// selectionmode must be intersection
var selMode = myMap.getSelectionMode();
// change mode if needed
if(selMode != "Intersection"){
myMap.setSelectionMode("Intersection");
}
// get the maplayer on which you'd like to select (a) polygon(s)
var mapLayer = myMap.getMapLayer("Parcel");
// select all objects on the layer intersected by the created polygon,
// use null to select from all layers
myMap.selectPolygonEx(mapLayer,tempCollection);
// change mode back if needed
if(selMode != "Intersection"){
myMap.setSelectionMode("Centroid");
}
var mySelection=myMap.getSelection().getMapObjectsEx('Parcel');
var key=mySelection.item(0).getKey();
myMap.setAutoRefresh(true);
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.