[mapserver-users] geomfromtext (POSTGIS) in C# or other language...
Tamas Szekeres
szekerest at gmail.com
Thu Sep 18 14:32:56 PDT 2008
Paul,
You should probably do the following steps when creating a new layer
from scratch:
// Register OGR
Ogr.RegisterAll();
// Get the postgis driver
Driver drv = Ogr.GetDriverByName("PostgreSQL");
// Create the datasource
DataSource ds = drv.CreateDataSource( [data source name], new string[] {} );
// Create the layer
Layer layer = ds.CreateLayer( [layer name], null,
wkbGeometryType.wkbPoint, new string[] {} );
// Adding attribute fields to the layers if needed
FieldDefn fdefn = new FieldDefn( "Name", FieldType.OFTString );
fdefn.SetWidth(32);
layer.CreateField( fdefn, 1 ) ;
// Adding features to the layer
Feature feature = new Feature( layer.GetLayerDefn() );
feature.SetField( "Name", "value" );
Geometry geom = Geometry.CreateFromWkt("POINT(47.0 19.2)");
feature.SetGeometry( geom );
layer.CreateFeature( feature );
Best regards,
Tamas
2008/9/18 Paul james <pauljame at gmail.com>:
> Thanks Thamas...
> Thats sounds great...
> But, after I used Geometry.CreateFromWkt function to convert my geometry,
> how can I add it to the PostGis Layer?
>
> On Thu, Sep 18, 2008 at 12:06 PM, Tamas Szekeres <szekerest at gmail.com>
> wrote:
>>
>> Paul,
>>
>> You could probably use the GDAL C# bindings and the
>> Geometry.CreateFromWkt function for this purpose.
>> For more information see the createdata.cs example in the gdal source
>> tree.
>>
>> Best regards,
>>
>> Tamas
>>
>>
>> 2008/9/18 Paul james <pauljame at gmail.com>:
>> > Hello Guys...
>> > I´d like to add a point in a Postgis layer... I´m able to do this using
>> > geomfromtext function (postgis)...
>> > I´d like to do that in C# ...
>> > Is that possible?
>> >
>> > Thankz
>> > _______________________________________________
>> > mapserver-users mailing list
>> > mapserver-users at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> >
>> >
>
>
More information about the MapServer-users
mailing list