Skip to main content

Reference Library

Go Search
Reference Library
  
Reference Library > Wiki Pages > Transform  

Transform

Transform functionality is significantly updated in MapDotNetServer version 6.5.  For earlier versions, please see Transform - version 6.1.2.
 
Overview
 
Transform operations convert geometry between different Coordinate Reference Systems.  These are supported through the TransformRequest and TransformResponse objects in the Common .Net SDK and by the MapControlBridge.Transform method.  By default, MDNS does transforms internally.  Note that although TransformRequest also provides support for buffering, the internal engine (Proj) does not support buffering.  See "Transforms via Database" below for buffering support.
 
Example
 
// set up request
TransformRequest tr = new TransformRequest();
ProjCoordSys pcsFrom = new ProjCoordSys();
pcsFrom.ID = 4326;
tr.SourceShapeCoordSys = pcsFrom;
ProjCoordSys pcsTo = new ProjCoordSys();
pcsTo.ID = 2238;
tr.ResultShapeCoordSys = pcsTo;
tr.AddShape(mapPoint84);

// reproject
TransformResponse tresp = MapControlBridge1.Transform(tr);

// obtain the new shape
if (tresp.Error != null)
{
    // handle error
}
else
{
    Point utmpt = Point.Deserialize(tresp.Shapes[0]);
    // etc.
 
Transforms via Database
 
MDNS can also pass transforms to an underlying database.  With this support comes the ability to buffer shapes, either along with a coordinate reference system transformation or as an isolated operation.  In order to do this, the MAP file for the Map in use by the MapControlBridge must provide TransformConnectionType and TransformConnectionString metadata keys.  TransformConnectionType can be "MS_POSTGIS", "MS_SDE", "MS_ORACLESPATIAL", "MS_SPATIALDB", or "MS_MSSQL2008" and TransformConnectionString should be an appropriate connection string.
 
The Sql Server connectors- "MS_SPATIALDB" and "MS_MSSQL2008"- do not support coordinate transformations and can only be used for buffering.
 
TransformRequest Class
 
The TransformRequest class encapsulates a request to transform or buffer a set of shapes.  Properties include
 
  • ConnectionType - string representing the desired connection type, if not using the internal transformation engine.
  • ConnectionString - connection information in map file format appropriate for the ConnectionType used.  Not needed when using the internal transformation engine.
  • SourceShapeCoordSys - a CoordSys object representing the coordinate reference system that the shapes are in prior to transformation.  If the TransformRequest is being used only to buffer, this may be set null.  If this is null, ResultShapeCoordSys should also be null.
  • ResultShapeCoordSys - a CoordSys object representing the coordinate reference system that the shapes should be transformed into.  If the TransformRequest is being used only to buffer, this may be set null.  If this is null, SourceShapeCoordSys should also be null. 
  • InterimBufferingProjection - a CoordSys representing a projected coordinate reference to use during a buffering operation.  An InterimBufferingProjection should be used when buffering is being done and either of the following is true:

    In either case, InterimBufferingProjection should be a  projected coordinate reference system that uses the relevant geographic coordinate system as its underlying reference system.  The reason for projecting the data prior to transformation is that units in the X and Y dimensions are always of equal distance in a projected coordinate reference system but this is not true for a geographic coordinate system.

    Review the CoordSys entry for usage information.

  • ResultShapeBufferDistance - the distance to buffer the output shapes by.  Any non-zero value indicates that buffering is desired.  This should be in InterimBufferingProjection units if InterimBufferingProjection is not null, or either SourceShapeCoordSys or ResultShapeCoordSys units depending on the value of the BufferAndTransformSequence property, or in units of the coordinate system used by the shapes if buffering is the only operation performed.
  • BufferAndTransformSequence - when both buffering and transformation are requested, this indicates the order in which the operations are to be performed.
  • Shapes - this is a list of serialized shape strings.  It is easiest to use the Add method of the TransformRequest class to add shapes to this list. 

 

TransformResponse Class

TranformResponse encapsulates the response to a TransformRequest.  There are two properties.

 

  • Error - any error that prevented the requested transformations.
  • Shapes - a list of serialized shapes in the same order as the shapes in the TransformRequest.  Use Shape.DeserializeShape to deserialize them and then cast them back to the original type if unbuffered or to Polygon if buffered.

 

MapControlBridge.Transform

This method takes a TransformRequest object, passes it to the FeatureService for transformation, and returns the resulting TransformResponse.

 

 

 

Last modified at 11/11/2008 6:13 PM  by WEB\mark