LuciadRIA can convert coordinates of objects such as points from one coordinate reference system to another.
To perform such a conversion, you first need to create a
Transformation object using the factory methods in the
Program: Transforming points between georeferences shows how the
MouseLocationComponent, which displays the coordinates under the mouse pointer on the screen, uses transformations.
The code creates a transformation from the map’s
CoordinateReference, which typically expresses coordinates in meters, to an arbitrary output
CoordinateReference defaults to WGS84, which expresses coordinates in latitude and longitude degrees.
Together with the transformation, it creates points that hold transformation results.
When the mouse moves on the screen,
event objects with location of the mouse in the browser window are passed to the
With this location, you can calculate the location of the mouse pointer on the map.
transform() on the Map’s
viewtoMapTransformation, you transform the view coordinates, stored in
this._tempViewPoint, to coordinates on the map .
At this point,
this._tempMapPoint has the location on the map in meters.
To know the location in latitude/longitude degrees, you pass
this._tempMapPoint to the
transform() method of the created transformation.
The location on the globe under the mouse pointer is available in
//transform points from view coordinates (in pixels) to map coordinates (in meters) this._tempViewPoint.move2D( event.clientX - this._mapNodePosition.left, event.clientY - this._mapNodePosition.top ); this._map.viewToMapTransformation.transform(this._tempViewPoint, this._tempMapPoint); //transform the point in map coordinates to the output reference (latitude/longitude) this._transformation.transform(this._tempMapPoint, this._tempModelPoint);
On a 3D map, the
In a 2D map, the