[Geoserver-devel] ShapeFiles and PostGIS

Hello list !

I'm searching for a way to add shapes from a shapefile, to a feature in a PostGIS Database using Geoserver. (assuming the feature already exists, and the shapes structure is the same as described in the feature's schema)
My first idea was to extract data from the shapefile, and to build GML transaction queries. Then I would have Geoserver execute my queries, and add the shapes to the postGis database. But this would be a huge work for me (the easiest way I found is to study "shp2pgsl" source code and to modify it so that it outputs a GML query).
That's why I'd like to know if there is a simpler way.

Since Geoserver can handle shapefiles, I had an idea :
I could open my shapefile with Geoserver, using a GetFeature request; and then I could easily transform the output into a insert request tragetting the feature in the postGis database.

So the first thing to do is to create a new feature type for my shapefile which is exactly the same as the one for my PostGis table, but with :
<DatasourceParams>
   <url>file://home/...wherever/the/file/is.shp</url>
</DatasourceParams>
(instead of postgis connection settings in the infos.xml file of the feature.)

But there, I have a problem :
The capabilities document doesn't show the new feature type.
That's why I ask the question : Is it possible to have both postGis and shapefiles features types on the same geoServer ?
The answer must be 'yes'.... But I can't find why it doesn't work...
Maybe it's because I'm on windows and my shapefile url is something like
<Url>file:c:/program files/easyphp/www/mapserverimage/upload/upload_ligne_electrique.shp</Url>
I also tried DOS name :
<Url>file:c:/progra~1/easyphp/www/mapser~1/upload/upload~3.shp</Url>
But I get the same result ....

Maybe someone can help me !
And if you have some other ideas on how to import shapes from a shapefile to a PostGis database... Let me know !
(Sorry for my bad english, I hope this mail is understandable !!)

Steph

_________________________________________________________________
Téléchargez gratuitement MSN Messenger ! http://www.msn.fr/msger/default.asp

Quoting "W. Steph" <chewbizz@anonymised.com>:

Hello list !

I'm searching for a way to add shapes from a shapefile, to a feature
in a
PostGIS Database using Geoserver. (assuming the feature already
exists, and
the shapes structure is the same as described in the feature's
schema)
My first idea was to extract data from the shapefile, and to build
GML
transaction queries. Then I would have Geoserver execute my queries,
and add
the shapes to the postGis database. But this would be a huge work for
me
(the easiest way I found is to study "shp2pgsl" source code and to
modify it
so that it outputs a GML query).
That's why I'd like to know if there is a simpler way.

Is there a reason you can't just use the output of shp2pgsql directly?
That's how I get all of my shapefile information into postgis. What I
do is run shp2pgsql shape (not sure of the params) > feature.sql, and
then call psql -f feature.sql dbname, where dbname is the database I
want the information to go in to. The shp2pgsql was made to put
shapefiles into postgis, and will do a much better job than getting the
output from the shapefile into gml and then inserting the gml. That
should work in theory, but in practice could easily loose a bit that
shp2pgsql won't. And if you want to do more than one shapefile into
the same database, if they have the same fields, you can do the second
ones with a -a argument, I believe, which makes it so it does not
create a new table, it just does the insert operations.

Since Geoserver can handle shapefiles, I had an idea :
I could open my shapefile with Geoserver, using a GetFeature request;
and
then I could easily transform the output into a insert request
tragetting
the feature in the postGis database.

So the first thing to do is to create a new feature type for my
shapefile
which is exactly the same as the one for my PostGis table, but with
:
<DatasourceParams>
   <url>file://home/...wherever/the/file/is.shp</url>
</DatasourceParams>
(instead of postgis connection settings in the infos.xml file of the

feature.)

But there, I have a problem :
The capabilities document doesn't show the new feature type.
That's why I ask the question : Is it possible to have both postGis
and
shapefiles features types on the same geoServer ?
The answer must be 'yes'.... But I can't find why it doesn't
work...
Maybe it's because I'm on windows and my shapefile url is something
like
<Url>file:c:/program

files/easyphp/www/mapserverimage/upload/upload_ligne_electrique.shp</Url

Yes, it's probably a problem with the url. For one I think url needs
to be in all lowercase. You might also try the <filename> tag (I think
that's what I named it, sorry for being unsure, but I don't have easy
access to all my code and documentation right now). This will go under
the datasource params tag, just like url, but you only put the name of
the shapefile. To use this you have to have the shapefile in the same
directory, so move upload_ligne_eletricque.shp to
geoserver/misc/data/featureTypes/, along with the .dbf and .shx files.

There's a section on shapefile support here:

http://geoserver.sourceforge.net/documentation/user/advanced.htm

So try it out with the filename and see if you can get it working. But
to get shapefiles into postgis, I'd say just use shp2pgsql directly.

Chris

I also tried DOS name :
<Url>file:c:/progra~1/easyphp/www/mapser~1/upload/upload~3.shp</Url>
But I get the same result ....

Maybe someone can help me !
And if you have some other ideas on how to import shapes from a
shapefile to
a PostGis database... Let me know !
(Sorry for my bad english, I hope this mail is understandable !!)

Steph

_________________________________________________________________
Téléchargez gratuitement MSN Messenger !
http://www.msn.fr/msger/default.asp

-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel