MapGuide API Reference
|
An MgCurvePolygon is a region, defined by 1 exterior boundary and 0 or more interior boundaries. More...
Public Member Functions | |
virtual MgGeometricEntity * | Copy () |
virtual INT32 | GetDimension () |
virtual MgCurveRing * | GetExteriorRing () |
Gets the exterior ring of the polygon. | |
virtual INT32 | GetGeometryType () |
virtual MgCurveRing * | GetInteriorRing (INT32 index) |
virtual INT32 | GetInteriorRingCount () |
virtual bool | IsClosed () |
virtual bool | IsEmpty () |
virtual MgGeometricEntity * | Transform (MgTransform *transform) |
Returns a transformed copy of this geometric entity. |
An MgCurvePolygon is a region, defined by 1 exterior boundary and 0 or more interior boundaries.
$geometryFactory = new MgGeometryFactory(); $curveSegmentCollection = new MgCurveSegmentCollection(); $curveRingCollection = new MgCurveRingCollection(); // create first curve segment for the external boundary $startCoordinate = $geometryFactory->CreateCoordinateXY(0,2); $controlCoordinate = $geometryFactory->CreateCoordinateXY(2,4); $endCoordinate = $geometryFactory->CreateCoordinateXY(4,2); $arcSegment = $geometryFactory->CreateArcSegment($startCoordinate, $endCoordinate, $controlCoordinate); $index = $curveSegmentCollection->Add($arcSegment); // create second curve segment for the external boundary $startCoordinate = $geometryFactory->CreateCoordinateXY(4,2); $controlCoordinate = $geometryFactory->CreateCoordinateXY(2,0); $endCoordinate = $geometryFactory->CreateCoordinateXY(0,2); $arcSegment = $geometryFactory->CreateArcSegment($startCoordinate, $endCoordinate, $controlCoordinate); $index = $curveSegmentCollection->Add($arcSegment); // create curve ring for the external boundary $exteriorCurveRing = $geometryFactory->CreateCurveRing($curveSegmentCollection); // clear the collection before adding the next curve segment $curveSegmentCollection->Clear(); // create first curve segment for an internal boundary $startCoordinate = $geometryFactory->CreateCoordinateXY(1,2); $controlCoordinate = $geometryFactory->CreateCoordinateXY(2,3); $endCoordinate = $geometryFactory->CreateCoordinateXY(3,2); $arcSegment = $geometryFactory->CreateArcSegment($startCoordinate, $endCoordinate, $controlCoordinate); $index = $curveSegmentCollection->Add($arcSegment); // create second curve segment for an internal boundary $startCoordinate = $geometryFactory->CreateCoordinateXY(3,2); $controlCoordinate = $geometryFactory->CreateCoordinateXY(2,1); $endCoordinate = $geometryFactory->CreateCoordinateXY(1,2); $arcSegment = $geometryFactory->CreateArcSegment($startCoordinate, $endCoordinate, $controlCoordinate); $index = $curveSegmentCollection->Add($arcSegment); // create curve ring for an internal boundary $interiorCurveRing = $geometryFactory->CreateCurveRing($curveSegmentCollection); $index = $curveRingCollection->Add($interiorCurveRing); // create curve polygon $curvePolygon = $geometryFactory->CreateCurvePolygon($exteriorCurveRing, $curveRingCollection); // print out the Agf Text string for the geometry $curvePolygonAgfText = $wktReaderWriter->Write($curvePolygon); echo "AGF Text representation of CurvePolygon: $curvePolygonAgfText\n";
using OSGeo.MapGuide; private MgWktReaderWriter wktReaderWriter; private MgGeometryFactory geometryFactory; private MgCurvePolygon cpnEr0224422002Ir12233212; private double[,] as022042 = { { 0, 0 }, { 0, 2 }, { 2, 0 }, { 4, 2 } }; private double[,] as422402 = { { 0, 0 }, { 4, 2 }, { 2, 4 }, { 0, 2 } }; private double[,] as122332 = { { 0, 0 }, { 1, 2 }, { 2, 3 }, { 3, 2 } }; private double[,] as322112 = { { 0, 0 }, { 3, 2 }, { 2, 1 }, { 1, 2 } }; private double[][,] cpEr0220422402; private double[][,] cpIr122332112; private double[][][,] cpEr0220422402Ir122332112Data; private String geometryAgfText; // The following BNF is for the construction of a string representation of the geometry // <CurvePolygon> ::= '(' <CurveStringCollection> ')' // <CurveStringCollection> ::= <CurveString> // | <CurveStringCollection> ',' <CurveString> // See the comments preceding CreateACurveStringXY() in the example code for MgCurveString // for the rest of the BNF. public MgCurvePolygon CreateACurvePolygonXY(double[][][,] ringsData) { MgCurveSegmentCollection segments = CreateACurveSegmentCollectionXY(ringsData[0]); MgCurveRing exteriorRing = geometryFactory.CreateCurveRing(segments); MgCurveRingCollection interiorRings = new MgCurveRingCollection(); for (int i = 1; i < ringsData.GetLength(0); i++) { segments = CreateACurveSegmentCollectionXY(ringsData[i]); interiorRings.Add(geometryFactory.CreateCurveRing(segments)); } return geometryFactory.CreateCurvePolygon(exteriorRing, interiorRings); } geometryFactory = new MgGeometryFactory(); cpEr0220422402 = new double[2][,]; cpEr0220422402[0] = as022042; cpEr0220422402[1] = as422402; cpIr122332112 = new double[2][,]; cpIr122332112[0] = as122332; cpIr122332112[1] = as322112; cpEr0220422402Ir122332112Data = new double[2][][,]; cpEr0220422402Ir122332112Data[0] = cpEr0220422402; cpEr0220422402Ir122332112Data[1] = cpIr122332112; cpnEr0224422002Ir12233212 = CreateACurvePolygonXY(cpEr0220422402Ir122332112Data); // print out the Agf Text string for the geometry wktReaderWriter = new MgWktReaderWriter(); geometryAgfText = wktReaderWriter.Write(cpnEr0224422002Ir12233212); // geometryAgfText now contains: // "CURVEPOLYGON XY (( 0 2 (CIRCULARARCSEGMENT( 2 0, 4 2), CIRCULARARCSEGMENT( 2 4, 0 2))), ( 1 2 ( CIRCULARARCSEGMENT( 2 3, 3 2), CIRCULARARCSEGMENT( 2 1, 1 2))))"