Select to view content in your preferred language

Reproject a Graphic from 102100 to 4326

4587
12
Jump to solution
09-25-2015 09:07 AM
FlorianCADOZ
Occasional Contributor

Hello,

Here I have two graphics ( one is a polygon and the other one is compound of several points ) and my objective is to produce something that looks like this: ArcGIS API for JavaScript Sandbox

My problem is that the polygon is in 4326 , the map is apparently (not sure ) in 102100 , and the points are in 4326 and apparently I have a problem when using this function:

        relationParams.geometries1 = graphicsUtils.getGeometries([this.entry4Analysis.featureSet.features[0]]);

        relationParams.geometries2 = graphicsUtils.getGeometries([this.spatialFilter4Analysis.graphics[2]]);

        relationParams.relation = RelationParameters.SPATIAL_REL_WITHIN;

           

        this.geometryService.relation(relationParams, this.addRelateResultsToMap);

So I tried different syntax (like : .setOutSpatialReference) to change the projection of one or other of the graphics when I launch the spatial analysis but nothing happens...

So now I really need help...

Thank you very much by advance !

0 Kudos
12 Replies
FlorianCADOZ
Occasional Contributor

woh' I really don't understand why the this.spatialFilter4Analysis.graphics[2].geometry return a different thing that the graphicsUtils.getGeometries([this.entry4Analysis.featureSet.features[2]]) but right now ain't got no error with the .contains() function !

Nevertheless, ain't got any alert so it didn't found points in my polygon and this is not normal...

Do you know if the different spatial reference could be a raison of this fail ?

For now, I need to specify a polygon in particular but in a second time I will have to use different polygon so I think I'll try to make an union of them !

(Thanks a lot for your last comment, it was really usefull!)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Florian,

    Since your points are 102100 and your Poly is 4326 you can just use esri/geometry/webMercatorUtils to project your points to geographic (4326) before you try the poly.contains.

var point = webMercatorUtils.webMercatorToGeographicthis.entry4Analysis.featureSet.features[0].geometry);

if(poly.contains(point)){

    alert('hello');

}

FlorianCADOZ
Occasional Contributor

Yes It was exactly that ! Thank you very much for your help !!!

0 Kudos