Get coordinates in planar

290
1
Jump to solution
05-31-2022 10:38 AM
JamesCrandall
MVP Frequent Contributor

Edit: I am open to any solution -- simple is better, GeometryService/Engine whatever works.

Back again, lots of interesting requirements lately!

This time I'm attempting to get the x/y values of point geometry in 102100/3857 as planar coordinates (wkid 2881).  Is there a simplified projectAs() function in the ESRI Javascript 3.x?

I've been attempting to implement projection but not having success with the overcoming errors with the geoTransformation.

 

 

 

               layer.layerObject.queryFeatures(query, function (f) {
                            const inSpatialReference = new SpatialReference({ wkid: 102100 });
                            const spSpatialReference = new SpatialReference({ wkid: 2881 });
                            var geoT = projection.getTransformations(inSpatialReference, spSpatialReference)
                            for (var i in f['features']) {                                
                                var facObj = Object.assign({}, f.features[i]['attributes']);

                                const point = new Point(f.features[i].geometry, inSpatialReference);
                                const projectedPoint = projection.project(point, spSpatialReference, geoT);

                                facObj.x = projectedPoint.x
                                facObj.y = projectedPoint.y

 

 

 

I have a facObj that I just need to apply the xy planar coordinate values.

0 Kudos
1 Solution

Accepted Solutions
JamesCrandall
MVP Frequent Contributor

Solved with client-side esri/geometry/projection

 

projection.load().then(function (evt) {
                            const inSpatialReference = new SpatialReference({ wkid: 102100 });
                            const spSpatialReference = new SpatialReference({ wkid: 2881 });
                            const point = new Point(f.features[i].geometry, inSpatialReference);
                            var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
                            const projectedPoint = projection.project(point, spSpatialReference);

                            this.facObj.x = Math.round(projectedPoint.x);
                            this.facObj.y = Math.round(projectedPoint.y);

 

View solution in original post

0 Kudos
1 Reply
JamesCrandall
MVP Frequent Contributor

Solved with client-side esri/geometry/projection

 

projection.load().then(function (evt) {
                            const inSpatialReference = new SpatialReference({ wkid: 102100 });
                            const spSpatialReference = new SpatialReference({ wkid: 2881 });
                            const point = new Point(f.features[i].geometry, inSpatialReference);
                            var geoT = projection.getTransformation(inSpatialReference, spSpatialReference)
                            const projectedPoint = projection.project(point, spSpatialReference);

                            this.facObj.x = Math.round(projectedPoint.x);
                            this.facObj.y = Math.round(projectedPoint.y);

 

0 Kudos