[Gdal-dev] Create Polygon in OGR / C#
Jean Michel PIERRET
jmp at geosys.com
Tue Jul 24 13:27:58 EDT 2007
Hi,
I would like transform a geometry structure in a OGR.Geometry.
Struct MyGeometry
{
bool [] exterior = null;
int [] partStarts = null;
int [] partEnds = null;
double [] padfX = null;
double [] padfY = null;
}
When I use the method ExportToWkt and CreateFromWkt it's very slow.
Now I have this method for the transformation :
Geometry gm = null;
Geometry g = null;
Geometry lr = null;
g = new Geometry(wkbGeometryType.wkbPolygon);
for (int i = 0; i < partStarts.Length; i++)
{
if (exterior[i])
{
if (i > 0)
{
if (gm == null)
gm = new Geometry(wkbGeometryType.wkbMultiPolygon);
gm.AddGeometry(g);
g.Dispose();
g = null;
}
if (g == null)
g = new Geometry(wkbGeometryType.wkbPolygon);
}
lr = new Geometry(wkbGeometryType.wkbLinearRing);
for (int j = partStarts[i]; j < partEnds[i]; j++)
lr.AddPoint(padfX[j], padfY[j], 0);
g.AddGeometry(lr);
lr.Dispose();
lr = null;
}
if (gm != null)
{
if (g != null)
{
gm.AddGeometry(g);
g.Dispose();
g = null;
}
return gm;
}
else
return g;
It works but it is not very quick, It's possible to have a function like in
the shapelib
SHPObject SHPCreateObject(ShapeType shpType, int nShapeId, int nParts, int[]
panPartStart, PartType[] paPartType, int nVertices, double[] adfX, double[]
adfY, double[] adfZ, double[] adfM);
Thanks for your support.
Best Regards.
<mailto:jmp at geosys.com> Jean-michel PIERRET - Poste 376
Tel : +33 (0)5 62 47 80 76
Mail : <mailto:jmp at geosys.com> jmp at geosys.com
GEOSYS SA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070724/0d166add/attachment.html
More information about the Gdal-dev
mailing list