PostgreSQL/PostGIS supports spatial extensions to enable the generation, storage, and analysis of geographic features. Additional information is available at http://postgis.net/
AspMap supports the Geometry and Geography data types. The PostgreSqlLayer class can be used to access and edit such spatial data. A sample table in a PostgreSQL database may look as the following:
NAME TYPE -------------------------------------- ID serial CITY_NAME character varying(40) STATE_NAME character varying(25) POPULATION integer GEOM geometry CREATE INDEX cities_geom ON cities USING gist (GEOM)
The GEOM field stores shapes in the Geometry data format. The GEOM field has a spatial index (USING gist GEOM) which is required to speed up spatial queries (for fast map rendering).
The ADO.NET framework does not have a built-in provider for PostgreSQL. The Npgsql provider (or any other PostgreSQL provider) is required. The Npgsql provider can be downloaded at http://npgsql.projects.pgfoundry.org/
Create a PostgreSqlLayer object and pass the connection string, table name and GEOM field to its constructor. It is also necessary to specify the FieldList property if you need attribute data for labeling or editing. Depending on the spatial data type, the DataType property should be specified.
Add the PostgreSqlLayer to the Map control using the AddLayer method:
Imports Npgsql Imports AspMap Imports AspMap.Data Dim connectionString As String = "Server=localhost;Database=DB;User ID=username;Password=password;" Dim tableName As String = "cities" Dim providerName As String = "Npgsql" Dim postgreLayer As PostgreSqlLayer postgreLayer = New PostgreSqlLayer (providerName, connectionString, tableName, "GEOM") postgreLayer.FieldList = "ID, CITY_NAME, POPULATION" postgreLayer.DataType = PostgreSqlDataType.Geometry Dim layer As Layer = map.AddLayer(postgreLayer)
The PostgreSqlLayer class supports editing of data as described in the Editing Spatial and Attribute Data topic.
© 2018 VDS Technologies
|Converted from CHM to HTML with chm2web Standard 2.85 (unicode)|