12.07.2015 Views

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PostGIS</strong> <strong>1.5.8</strong> <strong>Manual</strong>44 / 310FILTER "type = ’highway’ and numlanes >= 4"3. My <strong>PostGIS</strong> layer draws much slower than my Shape file layer, is this normal?In general, the more features you are drawing into a given map, the more likely it is that <strong>PostGIS</strong> will be slower thanShape files. For maps with relatively few features (100s), <strong>PostGIS</strong> will often be faster. For maps with high feature density(1000s), <strong>PostGIS</strong> will always be slower. If you are finding substantial draw performance problems, it is possible that youhave not built a spatial index on your table.postgis# CREATE INDEX geotable_gix ON geotable USING GIST ( geocolumn );postgis# VACUUM ANALYZE;4. My <strong>PostGIS</strong> layer draws fine, but queries are really slow. What is wrong?For queries to be fast, you must have a unique key for your spatial table and you must have an index on that unique key.Youcan specify what unique key for mapserver to use with the USING UNIQUE clause in your DATA line:DATA "the_geom FROM geotable USING UNIQUE gid"5. Can I use "geography" columns (new in <strong>PostGIS</strong> 1.5) as a source for MapServer layers?Yes! MapServer understands geography columns as being the same as geometry columns, but always using an SRID of4326. Just make sure to include a "using srid=4326" clause in your DATA statement. Everything else works exactly thesame as with geometry.DATA "the_geog FROM geogtable USING SRID=4326 USING UNIQUE gid"5.1.3 Advanced UsageThe USING pseudo-SQL clause is used to add some information to help mapserver understand the results of more complexqueries. More specifically, when either a view or a subselect is used as the source table (the thing to the right of "FROM" in aDATA definition) it is more difficult for mapserver to automatically determine a unique identifier for each row and also the SRIDfor the table. The USING clause can provide mapserver with these two pieces of information as follows:DATA "the_geom FROM (SELECTtable1.the_geom AS the_geom,table1.gid AS gid,table2.data AS dataFROM table1LEFT JOIN table2ON table1.id = table2.id) AS new_table USING UNIQUE gid USING SRID=-1"USING UNIQUE MapServer requires a unique id for each row in order to identify the row when doing mapqueries. Normally it identifies the primary key from the system tables. However, views and subselects don’t automaticallyhave an known unique column. If you want to use MapServer’s query functionality, you need to ensure your view orsubselect includes a uniquely valued column, and declare it with USING UNIQUE. For example, you could explicitlyselect nee of the table’s primary key values for this purpose, or any other column which is guaranteed to be unique for theresult set.Note"Querying a Map" is the action of clicking on a map to ask for information about the map features in that location.Don’t confuse "map queries" with the SQL query in a DATA definition.USING SRID= <strong>PostGIS</strong> needs to know which spatial referencing system is being used by the geometries in order toreturn the correct data back to MapServer. Normally it is possible to find this information in the "geometry_columns" tablein the <strong>PostGIS</strong> database, however, this is not possible for tables which are created on the fly such as subselects and views.So the USING SRID= option allows the correct SRID to be specified in the DATA definition.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!