[OpenLayers-Users] insert spatial data into mysql
Arnd Wippermann
arnd.wippermann at web.de
Mon Dec 21 17:12:36 EST 2009
Hi,
If you not want to use WFS-T, you can manuell add your polygons to your db
with a server script.
I do this task by looping through the features of a vector layer, to get the
attributes and geometry of these features and and post them to a server
script. The script uses ODBC to insert the features geometry into my db.
var aspODBC = "..."; //server script to insert data into a MS Access MDB
via ODBC
var KATEGORIE = "AREAS";
var TABLE = "POLYGONS";
function SaveGeometry(vlayer)
{
var featuresCount = vlayer.features.length;
for(var i=0;i<featuresCount;i++)
{
insertData(table, vlayer.features[i].geometry);
}
clearVectorlayer();
}
function insertData(table, WKTString)
{
var POSITION = WKTString.toString();
var theUrl = aspODBC;
var data = { MODE: "INSERT",
TABLE : table,
POSITION : POSITION,
KATEGORIE: KATEGORIE
}
var myAjax = new OpenLayers.Ajax.Request(
theUrl,
{
method: 'post',
data : OpenLayers.Util.getParameterString(data),
headers :
{ "Content-Type": "application/x-www-form-urlencoded"
},
onComplete: showResponseINSERT,
onFailure: showResponseFailureINSERT
});
}
Updating and deleting features are also possible in this way. And with
MapServer and ogr-ODBC it's possible to retrieve this data via WMS or WFS.
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von MadAGu
Gesendet: Montag, 21. Dezember 2009 21:12
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] insert spatial data into mysql
well anyone?
--
View this message in context:
http://n2.nabble.com/insert-spatial-data-into-mysql-tp4164235p4200314.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list