MapGuide API Reference
|
An MgLineString is a curve with linear interpolation between points. More...
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. |
An MgLineString is a curve with linear interpolation between points.
$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";
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 )"