Hello All,
I know that this topic it's a bit old, but i found this widget very useful. I'm working with compiled and uncompiled version and I have an issue. My application based on Flex 3.6 is in the projected CRS 22033 (Camacupa projected). I'm trying to display coordinates in WGS84 (4326). But when you see the results I figure it out that the coordinates are being converted to another CRS which is 4220 (Camacupa Geographic). There is anyway to set the transformation parameters in the source code? with a specific wkid transformation?
Thanks in advance,
Dilson
I would like to hardcode the cod below to use the Datum transformation with WKID 1327. But I don't know exactly how do to it. This code is part of Coord Menu Widget
It's not getting the transformation parameters from geometry service.
#
package widgets.CoordinateMenu
{
import com.esri.ags.SpatialReference;
import com.esri.ags.events.GeometryServiceEvent;
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.tasks.GeometryService;
import com.esri.ags.tasks.supportClasses.ProjectParameters;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
public class Projector
{
public var geometryServiceURL:String;
public var geometryService:GeometryService;
public function Projector(geomServiceURL:String)
{
this.geometryServiceURL = geomServiceURL;
}
public function projectPoint(mapPoint:MapPoint, toWKID:Number, callbackFunction:Function, errorFunction:Function = null😞void
{
this.geometryService = new GeometryService(this.geometryServiceURL);
this.geometryService.addEventListener(GeometryServiceEvent.PROJECT_COMPLETE, callbackFunction);
if (errorFunction != null)
{
this.geometryService.addEventListener(FaultEvent.FAULT, errorFunction);
}
else
{
this.geometryService.addEventListener(FaultEvent.FAULT, function():void
{
Alert.show("Error projecting coordinates.","Error");
});
}
var projectParamaters:ProjectParameters = new ProjectParameters();
projectParamaters.outSpatialReference =new SpatialReference(toWKID);
projectParamaters.geometries = [mapPoint];
this.geometryService.project(projectParamaters);
//var outSpatialReference:SpatialReference = new SpatialReference(toWKID);
//this.geometryService.project([mapPoint],outSpatialReference);
}
}
}
Dilson... Lets try a few things.
I think it can be done... But I don't even have Flex Builder installed anymore to help much.
If we look at the "ProjectParameters" object I see it accepts a datumTransformation
Try adding that ..
Drew
Some general steps..
Import the class at the top of the file
STEP 1
import com.esri.ags.tasks.supportClasses.DatumTransform;
STEP 2
Locate the following line
var projectParamaters:ProjectParameters = new ProjectParameters();
STEP 3
Add the new code below the line above
var datumTransform:DatumTransform = new DatumTransform(); datumTransform.wkid=1327; projectParamaters.datumTransform = datumTransform;
STEP 4
Test.
Like i said, I don't even have Flex installed. Play around and see what you can do.
Drew
So what is the end result... Is is functioning as expected now?
Hi Andrew,
Sorry for not answer before, I was testing the modifications.I can compile the widget, with no error, but It`s still not working.
In fact I've noted that the default function to calculcate WGS84 is not working. It's converting the coordinates to Camacupa GCS (wkid 4220).
And even If i setup in coordinate system tag to calculate WGS84, it's also given as result Camacupa GCS. My map is in Camacupa Projected S33 (wkid:22033) and I able to project to Camacupa / TM 12 SE (wkid:22092), but not to WGS84 and using the transformation with or without the wkid 1327.
For some reason seems like the tool is ignoring the 4326 parameters.
Cheers
Hello,
It's working now Andrew, after I add the following lines:
projectParameters.datumTransform = datumTransform;
projectParameters.transformForward = true;
So my the final of my file is looking like:
var projectParameters:ProjectParameters = new ProjectParameters();
var datumTransform:DatumTransform = new DatumTransform();
datumTransform.wkid=1327;
projectParameters.datumTransform = datumTransform;
projectParameters.transformForward = true;
projectParameters.outSpatialReference =new SpatialReference(toWKID);
projectParameters.geometries = [mapPoint];
this.geometryService.project(projectParameters);
Thank you very much for taking your time to help with this issue, I highly appreciate The tool is still very useful after all this years!
Have a nice day!
Dilson
Thanks good to hear. I am glad it worked out.
Maybe one day i'll release a JS version of it... I just cant find the time right now
Hi Andrew, thanks for your prompt reply. I've read that, but when i try to add the following:
public var datumTransform:DatumTransform;
A got the error message "1046: Type was not found or was not a compile-time constant:". Maybe I'm missing to import some library.
Thanks,
Dilson
See step 1 in my post above....
'import com.esri.ags.tasks.supportClasses.DatumTransform;'