[Gdal-dev] Create Polygon in OGR / C#

Jean Michel PIERRET jmp at geosys.com
Wed Jul 25 11:47:28 EDT 2007


Hi,

 

I have changed all “AddGeometry” by “AddGeometryDirectly” and nothing has
changed. 

 

Also i have creates a method to convert my structure into "wkb" and i use
"Geometry.CreateFromWkb" but it's not more quick than the other method.

 

Any idea ?

 

    int cpt;

    byte [] bnbexterior = null;

 

    cpt = 0;

    wkb = new byte [wkbSize];

 

    if (this.ismulti)

    {

            cpt += 4;

            wkb[cpt++] = 6;

 

            bnbexterior = BitConverter.GetBytes(this.getNbExterior());

            if (BitConverter.IsLittleEndian)

                        Array.Reverse(bnbexterior);

            bnbexterior.CopyTo(wkb, cpt);

            cpt += 4;

    }

 

    for (int i = 0; i < this.partStarts.Length; i++)

    {

            byte [] bnbring = null, bnbpoint = null;

 

            if (i == 0 || this.exterior[i])

            {

                           cpt += 4;

                           wkb[cpt++] = 3;

                           bnbring =
BitConverter.GetBytes(this.getNbRing(i));

                           if (BitConverter.IsLittleEndian)

                                      Array.Reverse(bnbring);

                           bnbring.CopyTo(wkb, cpt);

                           cpt += 4;

            }

 

            bnbpoint = BitConverter.GetBytes(this.partEnds[i] -
this.partStarts[i]);

            if (BitConverter.IsLittleEndian)

                           Array.Reverse(bnbpoint);

            bnbpoint.CopyTo(wkb, cpt);

            cpt += 4;

 

            for (int j = this.partStarts[i]; j < this.partEnds[i]; j++)

            {

                           byte [] bX = null, bY = null;

 

                           bX = BitConverter.GetBytes(this.padfX[j]);

                           bY = BitConverter.GetBytes(this.padfY[j]);

 

                           if (BitConverter.IsLittleEndian)

                           {

                                          Array.Reverse(bX);

                                          Array.Reverse(bY);

                           }

 

                           bX.CopyTo(wkb, cpt);

                           cpt += 8;

                           bY.CopyTo(wkb, cpt);

                           cpt += 8;

            }

    }

 

Thanks.

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

 

 

-----Message d'origine-----
De : Tamas Szekeres [mailto:szekerest at gmail.com] 
Envoyé : mercredi 25 juillet 2007 01:14
À : Jean Michel PIERRET
Cc : gdal-dev at lists.maptools.org
Objet : Re: [Gdal-dev] Create Polygon in OGR / C#

 

Jean,

You might want to test with AddGeometryDirectly instead of AddGeometry so as
to avoid the extra geometry creations.

When you have a large number of points in the rings you might want to use
the CreateFromWkb method to avoid the number of invocations between the C#/C
interface. You can create a byte array containing the wkb of the polygon in
the C# side and call the static CreateFromWkb of the Geometry class with
that array. 

Currently we have no such function you have mentioned, and I'm not sure
about the proper signature to use (depending on the type of the geometry) if
needed.
 

Best regards,

Tamas 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070725/e106a0c1/attachment.html


More information about the Gdal-dev mailing list