Hi Maciej.

I have seen cases where the first record of the datasource is returned no matter what the query is.
You are likely seeing a different problem, but now you know :).

In the pretty picture you have drawn, the lower part shows the parcel (with the number three), which clearly touches the yellow parcel. AFAIK, there is no direct spatial operation that allows you to select only the grey one. You can however calculate the area of which the two polygons overlap, and filter out the yellow, based on overlapped area. You can choose to discard polygon with a very smal overlapping area, or only select the one with the largest overlapping area.

Is there a problem with only selecting parcels that intersect the actual point the user clicked on?

If you are actually using the point, you are likely using the OGR provider, and having this problem:
http://trac.osgeo.org/fdo/ticket/343

Regards, Kenneth Skovhede, GEOGRAF A/S



Maciej Skorczewski skrev:
Hi

my problem is with "SetSpatialFilter" , in my application user click on PARCEL (on map) , and after click on "get REGION name" application should try to search in which REGION (biger surface) is the PARCEL.


what i want to get is:

help image :)
http://img171.imageshack.us/img171/8450/51030812fq1.png

so when user click on small parcel (in grey REGION), first pictures he should get ID of big grey REGION.

i you see on second image if parcel is nearly yellow REGION user should get ID ONLY grey region ....


I try use all method like:

MgFeatureSpatialOperations::Intersects

it is work but i get all REGION who Intersects my parcel (yellow and grey region ), after try another MgFeatureSpatialOperations like:

MgFeatureSpatialOperations::Contains = 0
MgFeatureSpatialOperations::CoveredBy = 8
MgFeatureSpatialOperations::Crosses = 1
MgFeatureSpatialOperations::Disjoint = 2
MgFeatureSpatialOperations::EnvelopeIntersects = 10
MgFeatureSpatialOperations::Equals = 3
MgFeatureSpatialOperations::Inside = 9
MgFeatureSpatialOperations::Intersects = 4
MgFeatureSpatialOperations::Overlaps = 5
MgFeatureSpatialOperations::Touches = 6
MgFeatureSpatialOperations::Within = 7


but get wrong/or none results

That is may procedure
1. user click on map
2. he press button "REGION info"
3. application use Getselection method to get selected parcel info: ID,NAME, and x,y Coordinates
4. I create new polygon (Coordinates come from selected parcel)
5. i use SetSpatialFilter and by iteration on all map layer i  check
what layer is in selected polygon range (REGION).



//------------my code
$selectedFeatures2=array(); //REGION ID,NAME etc.
//$coords -- come from selected parcel (GetCoordinates())

//generate new polygon from selected parcel
$linearRing = $geometryFactory->CreateLinearRing($coords);
$parcel_polygon = $geometryFactory->CreatePolygon($linearRing, null);
$resourceService=$siteConnection->CreateService(MgServiceType::ResourceService);


///--------BEGIN layer iteration...on all map layer


$layer = $map->GetLayers()->GetItem($layer_name[$i]);
$resId = new MgResourceIdentifier($layer->GetFeatureSourceId());
$featureGeometry = $layer->GetFeatureGeometryName();
$featureClass = $layer->GetFeatureClassName();
$schemaAndClass = explode(":", $featureClass);
$featureService =$siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetSpatialFilter($featureGeometry,
$polygon,MgFeatureSpatialOperations::Intersects);


$featureReader = $featureService->SelectFeatures($resId, $layer->GetFeatureClassName(), $queryOptions);
                while ($featureReader->ReadNext())
{ $selectedFeatures2[]=array("layer_name"=>$featureReader->GetString('Layer'),"FeatureId"=>$featureReader->GetInt32('FeatureId'));
                }



///--------END layer iteration...on all map layer








Can you pleas give me some sample code for this?





macieksk
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to