MapGuide API Reference
 All Classes Functions Variables Enumerations Enumerator Friends
MgLineString Class Reference

An MgLineString is a curve with linear interpolation between points. More...

+ Inheritance diagram for MgLineString:

List of all members.

Public Member Functions

virtual MgGeometricEntity * Copy ()
virtual MgCoordinateIterator * GetCoordinates ()
 Returns an iterator that can be used to enumerate each of the line strings coordinates.
virtual INT32 GetDimension ()
 
virtual MgCoordinate * GetEndCoordinate ()
 
virtual INT32 GetGeometryType ()
 
virtual MgCoordinate * GetStartCoordinate ()
virtual bool IsClosed ()
virtual bool IsEmpty ()
 
virtual MgGeometricEntity * Transform (MgTransform *transform)
 Returns a transformed copy of this geometric entity.

Detailed Description

An MgLineString is a curve with linear interpolation between points.

Remarks:
Each consecutive pair of points defines a line segment. An instance of this class is constructed by calling a non-static MgGeometryFactory::CreateLineString() method and, once constructed, is immutable.
Example (PHP)
The following code shows the construction of an MgLineString instance containing 2 coordinates.

 $geometryFactory = new MgGeometryFactory();
 $coordinateCollection = new MgCoordinateCollection();
 $wktReaderWriter = new MgWktReaderWriter();

 // create first coordinate
 $coordinate = $geometryFactory->CreateCoordinateXY(0,2);
 $index = $coordinateCollection->Add($coordinate);
 echo "Coordinate added to coordinate collection at index: $index\n";

 // create second coordinate
 $coordinate = $geometryFactory->CreateCoordinateXY(2,2);
 $index = $coordinateCollection->Add($coordinate);
 echo "Coordinate added to coordinate collection at index: $index\n";

 // create LineString
 $lineString =
 $geometryFactory->CreateLineString($coordinateCollection);

 // print out the Agf Text string for the
 geometry$lineStringAgfText = $wktReaderWriter->Write(lineString);
 echo "AGF Text representation of line string: $lineStringAgfText\n";
Example (C#)
 using OSGeo.MapGuide;

 private MgWktReaderWriter wktReaderWriter;
 private MgGeometryFactory geometryFactory;
 private MgLineString ls1121;
 // the data for 1 linestring
 private double[,] da1121 = { { 1, 1 }, { 2, 1 } };
 private String geometryAgfText;

 public MgLineString CreateALineStringXY(double[,] lineStringData)
 {
     MgCoordinateCollection coords = new MgCoordinateCollection();
     for (int i = 0; i < lineStringData.GetLength(0); i++)
     {
         coords.Add(geometryFactory.CreateCoordinateXY(lineStringData[i,0], lineStringData[i,1]));
     }
     return geometryFactory.CreateLineString(coords);
 }

 geometryFactory = new MgGeometryFactory();
 ls1121 = CreateALineStringXY(da1121);

 // print out the Agf Text string for the geometry
 wktReaderWriter = new MgWktReaderWriter();
 geometryAgfText = wktReaderWriter.Write(ls1121);
 // geometryAgfText now contains:
 // "LINESTRING XY ( 1 1, 2 1 )"