Web API Reference | MapGuide Open Source

- Overview
- Modules
- Classes

# MgMultiLineString Class Reference
[MgMultiLineString]

An MgMultiLineString is a one-dimensional aggregate geometry whose elements are MgLineString geometries. More...

Inherits MgAggregateGeometry.

List of all members.

## Public Member Functions
virtual MgGeometricEntity * | Copy ()
virtual INT32 | GetCount ()
virtual INT32 | GetDimension ()
virtual INT32 | GetGeometryType ()
virtual MgLineString * | GetLineString (INT32 index)
virtual bool | IsClosed ()
virtual bool | IsEmpty ()
virtual MgGeometricEntity * | Transform (MgTransform *transform)

## Detailed Description

An MgMultiLineString is a one-dimensional aggregate geometry whose elements are MgLineString geometries.

Remarks:
  The line strings are not connected or ordered. An instance of this class is constructed by calling a non-static MgGeometryFactory::CreateMultiLineString() method and, once constructed, is immutable.

Example (PHP)
The following code shows the construction of an MgMultiLineString geometry. Review the MgLineString example code.

     // A helper class additional to those created in the
     // MgLineString example code is needed.
     $lineStringCollection = new MgLineStringCollection();

     // After each MgLineString geometry is constructed,
     // it is added to an MgLineStringCollection.
     $index = $lineStringCollection->Add($lineString);
     echo "A line string is added to a line string collection at index: $index\n";

     // construct the MgMultiLineString geometry
     $multiLineString = $geometryFactory->CreateMultiLineString($lineStringCollection);

     // print out the Agf Text string for the geometry
     $multiLineStringAgfText = $wktReaderWriter->Write($multiLineString);
     echo "AGF Text representation of MultiLineString: $multiLineStringAgfText\n";

Example (C#)
The CreateAMultiLineStringXY method calls the CreateALineStringXY method. The code for the CreateALineStringXY method is in the MgLineString example code.

     using OSGeo.MapGuide;

     private MgWktReaderWriter wktReaderWriter;
     private MgGeometryFactory geometryFactory;
     private MgMultiLineString mlsLs0121Ls1121;
     // the data for 1 linestring
     private double[,] da0121 = { { 0, 1 }, { 2, 1 } };
     // the data for another linestring
     private double[,] da1121 = { { 1, 1 }, { 2, 1 } };
     // the data for 2 linestrings
     private double[][,] mlsLs0121Ls1121Data;
     private String geometryAgfText;

     public MgMultiLineString CreateAMultiLineStringXY(double[][,] lineStrings)
     {
         MgLineStringCollection lines = new MgLineStringCollection();
         for (int i = 0; i < lineStrings.GetLength(0); i++)
         {
             lines.Add(CreateALineStringXY(lineStrings[i]));
         }
         return geometryFactory.CreateMultiLineString(lines);
     }

     geometryFactory = new MgGeometryFactory();
     mlsLs0121Ls1121Data = new double[2][,];
     mlsLs0121Ls1121Data[0] = da0121;
     mlsLs0121Ls1121Data[1] = da1121;
     mlsLs0121Ls1121 = CreateAMultiLineStringXY(mlsLs0121Ls1121Data);

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

Comments or suggestions? Send us feedback.