Learning the seven-Coordinate System of Building Applications with FME Objects

Source: Internet
Author: User

For GIS, a two-dimensional coordinate system is a plane reference grid used to measure the distance. A three-dimensional coordinate system is used to measure the distance in a three-dimensional space. A coordinate system is generally defined by map projection, an elliptical body and a datum, one or more weft wires, a central meridian, and horizontal or vertical displacement. Concept data model of the coordinate system of the FME object:

For the conceptual FMEOCoordSysManager data model, the FME object does not provide one-to-one APIs in the conceptual diagram. FMEOCoordSysManager provides attributes and methods to access these classes. Methods and attributes include:

Most FME object applications do not need to care about the coordinate system, because the general conversion Coordinate System of the FME object is sufficient for most applications, but some programs still need it, the FMEOCoordSysManager object provides powerful and flexible methods for defining coordinate systems.

The app that shares the shares in oni needs to define the Coordinate System. You need to read the Coordinate System Support Section in the FME Foundation manual, which introduces the basic information of the FME object supporting the Coordinate System, there are also some important information in the FME Readers and Writer manual. Each chapter contains a quick reference table that contains the Coordinate System Support (Support for Coordinate System) rows. If the value of this row is YES, reader can read the coordinate system information from the source dataset, and writer can write the coordinate system information to the target dataset. If the value is NO, the information of the coordinate system cannot be saved, and the element is an unknown coordinate system. writer cannot save the information of the coordinate system.

All the elements of the FME object are associated with a coordinate system, and can be converted between two different coordinate systems. First, changing the coordinate system is not the conversion element itself to the new coordinate system, this step is more like tagging. The second step is to transform the coordinate system and convert the elements themselves to the new coordinate system. This step is called reprojecting)

When the FME object reads a format that does not support the coordinate system, the element ry is associated with an Unknown coordinate system, when reader reads such a coordinate system, it may return that the element is associated with the Unknown coordinate system or the non-earth coordinate system. In either case, it is considered as an Unknown coordinate system during re-projection, if you re-project an element to Unkonwn, it is actually marked as Unknown:

In this chapter, you can learn:

  • Check the geometric element coordinate system
  • Mark all elements
  • Re-project all elements
  • Mark individual elements
  • Re-projection of individual elements
  • Create a temporary Coordinate System for a user session
  • Add a persistent coordinate system to the FME object

 

Check the geometric element coordinate system

If you read elements from a format that supports the coordinate system, your application needs to check the coordinate system of the ry to determine how to handle the elements. The following Code demonstrates how to use the getCoodrSysParms method, combined with ellipsoid, datum and unit attributes are used to obtain information about all coordinate systems of elements. The coordinate system information returns four string Arrays: fme_CoordSysParams, fmeUnitParams, fmeDatumParams, and fme_EllipsoidParams.

:

 

Sub GetCoordSys (ByRef fmeFeature As FMEOFeature ,_
ByRef fmeCoordSysParams As FMEOStringArray ,_
ByRef fmeUnitParams As FMEOStringArray ,_
ByRef fmeDatumParams As FMEOStringArray ,_
ByRef fmeEllipsoidParams As FMEOStringArray)
Dim sCoordSysName As String
Dim sUnitName As String
Dim sEllipsoidName As String
Dim sDatumName As String
Dim fmeCoordSysMan As FMEOCoordSysManager
Dim lPosition As Long
SCoordSysName = fmeFeature. coordSys
Set fmeCoordSysMan = m_fmeSession.coordSysManager
Set fmeCoordSysParams = fmeCoordSysMan. getCoordSysParms _

(SCoordSysName)
LPosition = GetIndex (fmeCoordSysParams, "UNIT ")
If lPosition> = 0 Then
SUnitName = fmeCoordSysParams. element (lPosition + 1)
Set fmeUnitParams = fmeCoordSysMan. unit (sUnitName)
End If
LPosition = GetIndex (fmeCoordSysParams, "DT_NAME ")
If lPosition> = 0 Then
SDatumName = fmeCoordSysParams. element (lPosition + 1)
Set fmeDatumParams = fmeCoordSysMan. datum (sDatumName)
LPosition = GetIndex (fmeDatumParams, "ELLIPSOID ")
If lPosition> = 0 Then
SEllipsoidName = fmeDatumParams. element (_
LPosition + 1)
Set fmeEllipsoidParams = fmeCoordSysMan. ellipsoid _
(SEllipsoidName)
End If
Else
LPosition = GetIndex (fmeCoordSysParams, "EL_NAME ")
If lPosition> = 0 Then
SEllipsoidName = fmeCoordSysParams. element (_
LPosition + 1)
Set fmeEllipsoidParams = fmeCoordSysMan. ellipsoid _
(SEllipsoidName)
End If
End If
End Sub

In the code above, the GetIndex function gets the index of the elements in the string array. If the specified element does not exist, GetIndex returns-1. The GetIndex function code is in the Working with Collections section.

Tip: when your reference program reads the directory-type dataset format that supports the coordinate system, all files in the directory are not necessarily identical coordinate systems, this is the first element coordinate system that the FME object will automatically re-project all elements to read.

If your application needs a coordinate system defined in WKT format, you can use the getCoordSysAsOGCDef method instead of getCoordSysParms. getCoordSysAsOGCDef supports multiple WKT formats.

Mark input Elements

A new coordinate system is usually required for the source dataset. Perform the following operations:

  • The source dataset is not associated with the coordinate system, and you want to mark it with one.
  • The coordinate system of the source dataset is incorrect, and you want to correct it.

The following code marks all input elements to the Beijing54.GK3d/CM-108E coordinate system:

FmeDirectives. append ("COORDSYS ")

FmeDirectives. append ("Beijing54.GK3d/CM-108E ")

Set m_fmeReader = m_fmeSession.createReader (strSourceFormat, True, fmeDirectives)

If the sourcePrompt method of FMEODialog reads information from the source dataset, you must specify the coordinate system options, for example:

BCompleted = fmeDialog. sourcePrompt ("","",_
StrSourceFormat, strSourceDataset, fmeuserdireves VES)

When the method returns, the user-specified Beijing54.GK3d/CM-108E coordinate system will be included in the COORDSYS, Beijing54.GK3d/CM-108E name value pairs of the fmeUserDirectives string array.

NOTE: If multiple pairs of COORDSYS are passed to the createReader method, the first pair is used.

 

Re-projection Elements

The following code re-projects all elements to the Beijing54.GK3d/CM-108E coordinate system:

FmeDirectives. app ("COORDSYS ")

FmeDirectives. app ("Beijing54.GK3d/CM-108E ")

Set m_fmeWriter = m_fmeSession.createWriter (_ strDestFormat, fmeDirectives)

If the target format does not support the coordinate system, re-projection is still executed.

If you use the destPrompt method to obtain information about the target dataset, you can set the coordinate system on your own. The Code is as follows:

BCompleted = fmeDialog. destPrompt ("", "", strDestFormat ,_
StrDestDataset, fmeuserdireves VES)

 

If the user specifies the Beijing54.GK3d/CM-108E coordinate system, the fmeUserDirectives string array will contain COORDSYS, 10TM115-83 value pairs when the method returns.

NOTE: If multiple pairs of COORDSYS are passed to the createReader method, the first pair is used.

 

Mark a single element

The coordSys attribute of FMEOFeature is used to mark elements to a new coordinate system, for example, the following code:

LFeatureCount = m_fmeFeatureVector.entries
For I = 0 To lFeatureCount-1
M_fmeFeatureVector.element (I). coordSys = "10TM115-27"
Next I

 

Create a temporary Coordinate System

As needed, your application can create a new coordinate system using the unit, datum, ellipsoid, and defineCoordSys methods.

Tip: the lifecycle of the coordinate system created in this method is equal to that of the session. The next section describes how to create a persistent coordinate system.

 

For example, the following code defines the new elliptical MyEllipsoid using the ellipsoid attribute, which can be applied to the session lifecycle.

FmeParameters. append ("E_RAD ")
FmeParameters. append ("6376950 ")
FmeParameters. append ("P_RAD ")
FmeParameters. append ("6356352.616 ")
FmeCoordSysMan. ellipsoid ("MyEllipsoid") = fmeParameters

Similarly, you can use the datum attribute to create a new datum table named MyDatum and use the MyEllipsoid elliptical body.

FmeParameters. Clear
FmeParameters. append ("ELLIPSOID ")
FmeParameters. append ("MyEllipsoid ")
FmeParameters. append ("USE ")
FmeParameters. append ("3 PARAMETER ")

Finally, the following code uses defineCoordSys to create a temporary Coordinate System for reference to MyDatum.

FmeParameters. Clear
FmeParameters. append ("PROJ ")
FmeParameters. append ("TM ")
FmeParameters. append ("UNIT ")
FmeParameters. append ("METER ")
FmeParameters. append ("DT_NAME ")
FmeParameters. append ("MyDatum ")
FmeParameters. append ("PARM1 ")
FmeParameters. append ("9 ")
FmeParameters. append ("ORG_LAT ")
FmeParameters. append ("0 ")
FmeParameters. append ("X_OFF ")
FmeParameters. append ("3500000 ")
FmeParameters. append ("Y_OFF ")
FmeParameters. append ("0 ")
FmeParameters. append ("MAP_SCL ")
FmeParameters. append ("1 ")
FmeParameters. append ("SCL_RED ")
FmeParameters. append ("1 ")
Call fmeCoordSysMan. defineCoordSys (fmeParameters ,_
SCoordSysName)

If your application needs to define a temporary coordinate system based on a string in WKT format, you can use the defineCoordSysFromOGCDef method with the defineCoordSysParms parameter. This method supports multiple WKT formats.

Create a persistent Coordinate System

A local file defining the coordinate system is automatically loaded by the FME Session object. The LocalCoordSysDefs. FME file in the Reproject subdirectory of the fme object installation directory. It contains a series of COORDINATE_SYSTEM_DEF, DATUM_DEF, ELLIPSOID_DEF, UNIT_DEF definitions, and application-specific coordinate systems.

Edit the file and add your own definition. For details, refer to the help section of FME online Coordinate Systems.

References:

Building Applications with FME Objects February 2005

Reprinted please indicate the source http://www.cnblogs.com/booolee

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.