[Geoserver-devel] Using postgis help

I just installed geoserver 1.0 as a webapplication in
tomcat 4.1.24 (jsdk 1.4.2) on win 2k. the example in
the "topp--road"-directory with the shapefile works
perfectly. to get some experience i tried to modify
the example so that it works with postgis. i applied
shp2sql to road.shp and loaded the data in a table
called 'road''. i didn't change the schema.xml but
modified the info.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Example info.xml file for a Shapefile Datasource.
-->
<featureType>
  <!-- Used for return of getCapabilities, and
internally. Required
            Must match the name of the shapefile
(without the extension) -->
  <Name>road</Name>

  <!-- Must be an epsg code. Others not yet supported.
Required -->
  <SRS>32118</SRS>

  <!-- These are optional service elements, not
required but recommended.
       Used in the TypeInfo sections of the
capabilities document. -->
  <Title>Random Road Centerlines</title>
  <Abstract>This is some random road
features</Abstract>
  <Keywords>road, New York City, TOPP</Keywords>
  <LatLonBoundingBox minx="-74.27000" miny="40.50000"
maxx="-73.80000" maxy="40.94000"/>

   <!-- This section tells GeoServer the parameters for
the backend
       data to be served with this featureType. Varies
for
       different datasources. The following is for
       a Postgis datasource. -->
         
  <DatasourceParams>
           
    <!-- The name of the host, generally localhost, if
the db is
               on another computer then its ip or name
may be used. -->
       <host>omni02</host>

             <!-- The port to connect on. Postgis
defaults to 5432. -->
       <port>5432</port>

       <!-- The name of the database containing this
feature -->
       <database>testdb</database>

       <!-- The user to connect with. Must have
permissions on
         the table -->
    <user>postgres</user>

    <!-- The password of the user. -->
    <passwd>manager</passwd>

    <!-- The name of the table. Must match the Name
element -->
    <table>road</table>

    <!-- Must always be postgis. -->
    <dbtype>postgis</dbtype>

  </DatasourceParams>
</featureType>

It is generating some output when I ran the command
http://localhost/geoserver/GetFeature?featureid=road.2
but it doesn't look right. The gml:coordinates should
not be 0,0,-1,-1. See below.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection
   xmlns="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:wfs="http://www.opengis.net/wfs&quot;
  
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance&quot;
   xs:schemaLocation="http://www.openplans.org/topp
                  
http://localhost:8080/geoserver/DescribeFeatureType?typeName=topp:road
                   http://www.opengis.net/wfs
                  
http://localhost:8080/geoserver/data/capabilities/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
   <gml:boundedBy>
    <gml:Box>
     <gml:coordinates>0,0 -1,-1</gml:coordinates>
    </gml:Box>
   </gml:boundedBy>
</wfs:FeatureCollection>

I can't see anything wrong in the Tomcat log:

324203 [FINEST] org.geotools.factory.FactoryFinder -
Searching system properties
324203 [FINEST] org.geotools.factory.FactoryFinder -
Key 'org.geotools.feature.FeatureTypeFactory' not
found
324219 [FINEST] org.geotools.factory.FactoryFinder -
Searching for service:
META-INF/services/org.geotools.feature.FeatureTypeFactory
324219 [FINEST] org.geotools.factory.FactoryFinder -
Reading Factory , has stream : false
324219 [FINEST] org.geotools.factory.FactoryFinder -
Service
'META-INF/services/org.geotools.feature.FeatureTypeFactory'
not found
324219 [FINEST] org.geotools.factory.FactoryFinder -
Resorting to default 324219 [FINEST]
org.geotools.factory.FactoryFinder - Creating instance
from 'org.geotools.feature.DefaultFeatureTypeFactory'
324219 [FINER]
org.geotools.data.postgis.PostgisDataSource - using
schema DefaultFeatureType [name=road , namespace= ,
abstract=false , types=(DefaultAttributeType [name=gid
, type=class java.lang.Integer ,
nillable=true],DefaultAttributeType [name=surface_ty ,
type=class java.lang.String ,
nillable=true],DefaultAttributeType [name=name ,
type=class java.lang.String ,
nillable=true],DefaultAttributeType [name=nlanes ,
type=class java.lang.Long ,
nillable=true],DefaultAttributeType [name=the_geom ,
type=class com.vividsolutions.jts.geom.MultiLineString
, nillable=true],)]
324234 [FINE] org.geotools.data.jdbc.ConnectionPool -
Getting available connection.
324234 [FINER]
org.geotools.data.postgis.PostgisDataSource - made
statement
324250 [FINER] AbstractFilter - ENTRY 22
324250 [FINE]
org.geotools.data.postgis.PostgisDataSource - Filter
in making sql is null
324250 [FINER]
org.geotools.data.postgis.PostgisDataSource - making
sql for 5 attributes
324250 [FINE]
org.geotools.data.postgis.PostgisDataSource - sql
statement is SELECT oid, "gid", "surface_ty", "name",
"nlanes", AsText(force_2d("the_geom")) FROM "road"
LIMIT 1000000;
324266 [FINE]
org.geotools.data.jdbc.ConnectionPool$ConnectionListManager
- Connection closed - adding to available connections.
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse -
successfully retrieved collection
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse - ended
feature
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse - GML is:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection
   xmlns="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:wfs="http://www.opengis.net/wfs&quot;
  
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance&quot;
   xs:schemaLocation="http://www.openplans.org/topp
                  
http://localhost:8080/geoserver/DescribeFeatureType?typeName=topp:road
                   http://www.opengis.net/wfs
                  
http://localhost:8080/geoserver/data/capabilities/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
   <gml:boundedBy>
    <gml:Box>
     <gml:coordinates>0,0 -1,-1</gml:coordinates>
    </gml:Box>
   </gml:boundedBy>
</wfs:FeatureCollection>

Can anyone help?

Thanks.

__________________________________________________
Do You Yahoo!?
Faster. Easier. Bingo.
http://sg.search.yahoo.com

What version of postgis are you using? Unless you're working off of the
cvs version of postgis I'm pretty positive that the featureid of road will
no longer be road.2. Featureid is determined by the backend database, and
in the case of postgis it generally sets a fairly high number. To use the
the featureid kvp you first need to do

http://localhost/geoserver/GetFeature?typename=road

and it should return a list of the road features. They will have the
proper fids, and then you can request them directly. The road.2 returns
no features because there is no road feature with road.2 as its featureid.

There is a known problem with namespace prefixes in kvps for featureid
requests, which is fixed in cvs, but I'm pretty sure that's not the issue
you're having.

As for Darren's suggestion, GeoServer does not yet handle srs's
intelligently enough for that to be an issue, but it was a good thought.

  Chris

On Mon, 27 Oct 2003, Dominic Chin wrote:

I just installed geoserver 1.0 as a webapplication in
tomcat 4.1.24 (jsdk 1.4.2) on win 2k. the example in
the "topp--road"-directory with the shapefile works
perfectly. to get some experience i tried to modify
the example so that it works with postgis. i applied
shp2sql to road.shp and loaded the data in a table
called 'road''. i didn't change the schema.xml but
modified the info.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Example info.xml file for a Shapefile Datasource.
-->
<featureType>
  <!-- Used for return of getCapabilities, and
internally. Required
            Must match the name of the shapefile
(without the extension) -->
  <Name>road</Name>

  <!-- Must be an epsg code. Others not yet supported.
Required -->
  <SRS>32118</SRS>

  <!-- These are optional service elements, not
required but recommended.
       Used in the TypeInfo sections of the
capabilities document. -->
  <Title>Random Road Centerlines</title>
  <Abstract>This is some random road
features</Abstract>
  <Keywords>road, New York City, TOPP</Keywords>
  <LatLonBoundingBox minx="-74.27000" miny="40.50000"
maxx="-73.80000" maxy="40.94000"/>

   <!-- This section tells GeoServer the parameters for
the backend
       data to be served with this featureType. Varies
for
       different datasources. The following is for
       a Postgis datasource. -->
         
  <DatasourceParams>
           
    <!-- The name of the host, generally localhost, if
the db is
               on another computer then its ip or name
may be used. -->
       <host>omni02</host>

             <!-- The port to connect on. Postgis
defaults to 5432. -->
       <port>5432</port>

       <!-- The name of the database containing this
feature -->
       <database>testdb</database>

       <!-- The user to connect with. Must have
permissions on
         the table -->
    <user>postgres</user>

    <!-- The password of the user. -->
    <passwd>manager</passwd>

    <!-- The name of the table. Must match the Name
element -->
    <table>road</table>

    <!-- Must always be postgis. -->
    <dbtype>postgis</dbtype>

  </DatasourceParams>
</featureType>

It is generating some output when I ran the command
http://localhost/geoserver/GetFeature?featureid=road.2
but it doesn't look right. The gml:coordinates should
not be 0,0,-1,-1. See below.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection
   xmlns="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:wfs="http://www.opengis.net/wfs&quot;
  
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance&quot;
   xs:schemaLocation="http://www.openplans.org/topp
                  
http://localhost:8080/geoserver/DescribeFeatureType?typeName=topp:road
                   http://www.opengis.net/wfs
                  
http://localhost:8080/geoserver/data/capabilities/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
   <gml:boundedBy>
    <gml:Box>
     <gml:coordinates>0,0 -1,-1</gml:coordinates>
    </gml:Box>
   </gml:boundedBy>
</wfs:FeatureCollection>

I can't see anything wrong in the Tomcat log:

324203 [FINEST] org.geotools.factory.FactoryFinder -
Searching system properties
324203 [FINEST] org.geotools.factory.FactoryFinder -
Key 'org.geotools.feature.FeatureTypeFactory' not
found
324219 [FINEST] org.geotools.factory.FactoryFinder -
Searching for service:
META-INF/services/org.geotools.feature.FeatureTypeFactory
324219 [FINEST] org.geotools.factory.FactoryFinder -
Reading Factory , has stream : false
324219 [FINEST] org.geotools.factory.FactoryFinder -
Service
'META-INF/services/org.geotools.feature.FeatureTypeFactory'
not found
324219 [FINEST] org.geotools.factory.FactoryFinder -
Resorting to default 324219 [FINEST]
org.geotools.factory.FactoryFinder - Creating instance
from 'org.geotools.feature.DefaultFeatureTypeFactory'
324219 [FINER]
org.geotools.data.postgis.PostgisDataSource - using
schema DefaultFeatureType [name=road , namespace= ,
abstract=false , types=(DefaultAttributeType [name=gid
, type=class java.lang.Integer ,
nillable=true],DefaultAttributeType [name=surface_ty ,
type=class java.lang.String ,
nillable=true],DefaultAttributeType [name=name ,
type=class java.lang.String ,
nillable=true],DefaultAttributeType [name=nlanes ,
type=class java.lang.Long ,
nillable=true],DefaultAttributeType [name=the_geom ,
type=class com.vividsolutions.jts.geom.MultiLineString
, nillable=true],)]
324234 [FINE] org.geotools.data.jdbc.ConnectionPool -
Getting available connection.
324234 [FINER]
org.geotools.data.postgis.PostgisDataSource - made
statement
324250 [FINER] AbstractFilter - ENTRY 22
324250 [FINE]
org.geotools.data.postgis.PostgisDataSource - Filter
in making sql is null
324250 [FINER]
org.geotools.data.postgis.PostgisDataSource - making
sql for 5 attributes
324250 [FINE]
org.geotools.data.postgis.PostgisDataSource - sql
statement is SELECT oid, "gid", "surface_ty", "name",
"nlanes", AsText(force_2d("the_geom")) FROM "road"
LIMIT 1000000;
324266 [FINE]
org.geotools.data.jdbc.ConnectionPool$ConnectionListManager
- Connection closed - adding to available connections.
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse -
successfully retrieved collection
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse - ended
feature
324266 [FINEST]
org.vfny.geoserver.responses.FeatureResponse - GML is:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection
   xmlns="http://www.openplans.org/topp&quot;
   xmlns:gml="http://www.opengis.net/gml&quot;
   xmlns:wfs="http://www.opengis.net/wfs&quot;
  
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance&quot;
   xs:schemaLocation="http://www.openplans.org/topp
                  
http://localhost:8080/geoserver/DescribeFeatureType?typeName=topp:road
                   http://www.opengis.net/wfs
                  
http://localhost:8080/geoserver/data/capabilities/wfs/1.0.0/WFS-basic.xsd&quot;&gt;
   <gml:boundedBy>
    <gml:Box>
     <gml:coordinates>0,0 -1,-1</gml:coordinates>
    </gml:Box>
   </gml:boundedBy>
</wfs:FeatureCollection>

Can anyone help?

Thanks.

__________________________________________________
Do You Yahoo!?
Faster. Easier. Bingo.
http://sg.search.yahoo.com

-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--