0

I need to create a HTML page that allows for creating a new PostGIS table in a specific database, through the GeoServer API. So I'm specifically interested in the Creating a PostGIS table part of this tutorial

I'm trying to create a HTML form (post) for that PHP script but I don't know how to start... I already have my Apache, Geoserver+Tomcat, PHP running but I'm a bit lost for that... Does this PHP code in the link work with a HTML form, prompting for the user to fill a form with $table, $geometry?

http://cnokello.blogspot.com/2012/09/geoserver-rest-api-with-php.html

In particular, I don't know where to put the lines at the bottom and beginning of the explanation page. Should they be on a separate page?

define("GEOSERVER_REST_HOST", "http://localhost:8080/geoserver/rest/");
define("GEOSERVER_USER", "username:password");

and

$data = An array with the following elements, at a minimum:
$data['transactType'] = "CREATE_POSTGIS_TABLE"
$data['contentType'] = "Content-type: text/xml"
$data['store'] = $t, details of the store to be created, which can be as shown below:

and:

$t = "<featureType>";
$t .= "<name>".$table."</name>";
$t .= "<nativeName>".$table."</nativeName>";
$t .= "<title>".$table."</title>";
$t .= "<srs>EPSG:4326</srs>";
$t .= "<attributes>";
$t .= "<attribute>";
$t .= "<name>the_geom</name>";
$t .= "<binding>com.vividsolutions.jts.geom.".$geometry."</binding>";
$t .= "</attribute>";
$t .= "<attribute>";
$t .= "<name>description</name>";
$t .= "<binding>java.lang.String</binding>";
$t .= "</attribute>";
$t .= "<attribute>";
$t .= "<name>timestamp</name>";
$t .= "<binding>java.util.Date</binding>";
$t .= "</attribute>";
$t .= "</attributes>";
$t .= "</featureType>";
Vince
  • 20,017
  • 15
  • 45
  • 64
Vincent Dc
  • 488
  • 3
  • 12
  • 1
    It's very poor security design to permit table creation through a web service, leaving you vulnerable to a denial of service attack. – Vince Jun 13 '22 at 12:32
  • @Vince for the moment, it's for the purpose of learning - then I will learn about authentifications, which are even more tricky for me – Vincent Dc Jun 13 '22 at 12:34
  • It's not about authentication. Table creation should simply NOT be permitted. Ever. Adding rows is risky enough (and only with a user which does not have create table permission, not the owner). – Vince Jun 13 '22 at 12:38
  • @Vince but basically when you want to allow a user to draw some features on an empty online map on his smartphone , to easily find it back home when he starts Qgis, a new table in Postgis isn't what you need? - or he'll have to save a geojson on his smartphone and copy it after – Vincent Dc Jun 13 '22 at 16:36
  • 1
    New table creation is NOT the way to accomplish that. It is the way to destroy your database by filling it with an unending pile of tables that may never be accessed again. – Vince Jun 13 '22 at 18:34
  • is adding data to postgis feasible and a solution? https://gis.stackexchange.com/questions/197708/automatically-refresh-my-wfs-layer-in-leaflet-when-adding-data-in-postgis @Vince – Vincent Dc Jul 09 '22 at 22:00

0 Answers0