Web API Reference | MapGuide Open Source

- Overview
- Modules
- Classes

# MgWktReaderWriter Class Reference
[MgWktReaderWriter]

Translates a string in AGF (Autodesk Geometry Format) Text format into an MgGeometry object and vice versa. See the AGF Text topic. . More...

Inherits MgGuardDisposable.

List of all members.

## Public Member Functions
| MgWktReaderWriter ()
| Constructor.
virtual MgGeometry * | Read (CREFSTRING wkt, MgTransform *transform)
| Reads a geometry object from a string in WKT format applying the specified transform during the read.
virtual MgGeometry * | Read (CREFSTRING wkt)
| Reads a geometry object from an AGF Text format.
virtual STRING | Write (MgGeometry *geometry, MgTransform *transform)
| Writes a geometry object to a string in WKT format applying the specified transform during the write.
virtual STRING | Write (MgGeometry *geometry)
| Writes a geometry object to a string in AGF Text format.

## Detailed Description

Translates a string in AGF (Autodesk Geometry Format) Text format into an MgGeometry object and vice versa. See the AGF Text topic. .

Example (PHP)

     $wktReaderWriter = new MgWktReaderWriter();
     $agfReaderWriter = new MgAgfReaderWriter();
     // In the string to geometry direction:
     $agfTextPoint = "POINT XY (0 0)";
     $pointGeometryFromWkt = $wktReaderWriter->Read($agfTextPoint);
     $byteReader = $agfReaderWriter->Write($pointGeometryFromAgfText);
     // In the geometry to string direction:
     $pointGeometryFromBytes = $agfReaderWriter->Read($byteReader);
     $agfTextPoint = $wktReaderWriter->Write($pointGeometryFromBytes);
     // prints "POINT XY (0 0)" to screen
     echo "$agfTextPoint\n";

Example (C#)

     private MgAgfReaderWriter agfReaderWriter;
     private MgWktReaderWriter wktReaderWriter;
     private MgPoint pt11FromText;
     private MgPoint pt11;
     private String pt11TextSpec = "POINT XY ( 1 1 )";
     private MgByteReader byteReader;
     private String geometryAgfText;

     agfReaderWriter = new MgAgfReaderWriter();
     wktReaderWriter = new MgWktReaderWriter();
     // In the string to geometry direction:
     pt11FromText = wktReaderWriter.Read(pt11TextSpec) as MgPoint;
     byteReader = agfReaderWriter.Write(pt11FromText);
     // In the geometry to string direction:
     pt11 = agfReaderWriter.Read(byteReader);
     geometryAgfText = wktReaderWriter.Write(pt11);
     // geometryAgfText now contains the text representation of the geometry

Comments or suggestions? Send us feedback.