[TinyOWS-users] A WFS 1.1.0 issue ?
Thomas Gratier
osgeo.mailinglist at gmail.com
Tue Jul 13 14:36:25 EST 2010
Hello list,
Some months ago, Alexander Schäfer see that there was a problem with WFS
1.1.0 to display a layer on the map, stored well in the database.
http://lists.maptools.org/pipermail/tinyows-users/2010-May/000086.htm
Is it always a known issue? An Openlayers issue? A config mistake from
myself?
When only switching to 1.0.0, the same code is perfectly fine and the layer
displays on the map.
I don't see the advantage of 1.1.0 version, so 1.0.0 is enought?
Regards
ThomasG
PS : below, my test code
--SQL--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE SCHEMA gis_schema
AUTHORIZATION postgres;
CREATE TABLE gis_schema.parcelle (
gid integer NOT NULL,
idu character varying(80),
supf numeric,
indp numeric,
autocad_el numeric,
the_geom public.geometry,
CONSTRAINT enforce_dims_the_geom CHECK ((public.st_ndims(the_geom) =
2)),
CONSTRAINT enforce_geotype_the_geom CHECK
(((public.geometrytype(the_geom) = 'MULTIPOLYGON'::text) OR (the_geom IS
NULL))),
CONSTRAINT enforce_srid_the_geom CHECK ((public.st_srid(the_geom) =
4326))
);
ALTER TABLE parcelle OWNER TO postgres;
CREATE SEQUENCE parcelle_gid_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
ALTER TABLE gis_schema.parcelle_gid_seq OWNER TO postgres;
ALTER SEQUENCE parcelle_gid_seq OWNED BY parcelle.gid;
SELECT pg_catalog.setval('parcelle_gid_seq', 1, true);
ALTER TABLE gis_schema.parcelle ALTER COLUMN gid SET DEFAULT
nextval('parcelle_gid_seq'::regclass);
ALTER TABLE gis_schema.parcelle
ADD CONSTRAINT parcelle_pkey PRIMARY KEY (gid);
CREATE INDEX parcelle_the_geom_gist ON parcelle USING gist (the_geom);
INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name,
f_geometry_column, coord_dimension, srid, type) VALUES ('', 'gis_schema',
'parcelle', 'the_geom', 2, 4326, 'MULTIPOLYGON');
<!--config.xml file-->
<tinyows online_resource="http://localhost/cgi-bin/tinyows"
schema_dir="/usr/local/tinyows/schema/">
<pg host="127.0.0.1" user="postgres" password="atlas" dbname="gavrelle"
port="5432"/>
<metadata name="TinyOWS Server"
title="TinyOWS Server - Gavrelle EP" />
<contact name="TinyOWS Server"
site="http://www.tinyows.org/"
email="tinyows-users at lists.maptools.org" />
<layer retrievable="1"
writable="1"
srid="4326"
queryable="1"
prefix="gavrelle"
server="localhost"
schema="gis_schema"
name="parcelle"
title="parcelles" />
</tinyows>
//javascript tinyows.js
var map, wfs;
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {
initialize: function(layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.layer = layer;
this.handler = new OpenLayers.Handler.Feature(
this, layer, {click: this.clickFeature}
);
},
clickFeature: function(feature) {
// if feature doesn't have a fid, destroy it
if(feature.fid == undefined) {
this.layer.destroyFeatures([feature]);
} else {
feature.state = OpenLayers.State.DELETE;
this.layer.events.triggerEvent("afterfeaturemodified",
{feature: feature});
feature.renderIntent = "select";
this.layer.drawFeature(feature);
}
},
setMap: function(map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.DeleteFeature"
});
function showMsg(szMessage) {
document.getElementById("message").innerHTML = szMessage;
setTimeout(
"document.getElementById('message').innerHTML = ''",2000);
}
function showSuccessMsg(){
showMsg("Transaction successfully completed");
};
function showFailureMsg(){
showMsg("An error occured while operating the transaction");
};
function init() {
map = new OpenLayers.Map('map', {
projection: new OpenLayers.Projection("EPSG:4326"),
units: "degrees",
maxResolution: "auto",
maxExtent: new OpenLayers.Bounds(-5.34, 41.92, 10.84, 51.59),
controls: [
new OpenLayers.Control.PanZoom()
]
});
var region = new OpenLayers.Layer.WMS(
"Region Carmen",
"http://ws.carmencarto.fr/WMS/34/patnat2008?",
{layers: 'Region', format: 'image/png'},
{projection:"EPSG:4326", units: "degrees", maxResolution: "auto",
maxExtent: new OpenLayers.Bounds(-5.34, 41.92, 10.84, 51.59)}
);
var saveStrategy = new OpenLayers.Strategy.Save();
saveStrategy.events.register("success", '', showSuccessMsg);
saveStrategy.events.register("failure", '', showFailureMsg);
wfs = new OpenLayers.Layer.Vector("Editable Features", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
projection: new OpenLayers.Projection("EPSG:4326"),
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
srsName: "EPSG:4326",
url: "http://localhost/cgi-bin/tinyows",
featureNS : "localhost",
featureType: "parcelle",
geometryName: "the_geom",
schema: "
http://localhost/cgi-bin/tinyows?service=wfs&request=DescribeFeatureType&version=1.0.0&typename=gavrelle:parcelle
",
extractAttributes: true
})
});
map.addLayers([region, wfs]);
var panel = new OpenLayers.Control.Panel(
{'displayClass': 'customEditingToolbar'}
);
var navigate = new OpenLayers.Control.Navigation({
title: "Pan Map"
});
var draw = new OpenLayers.Control.DrawFeature(
wfs, OpenLayers.Handler.Polygon,
{
title: "Draw Feature",
displayClass: "olControlDrawFeaturePolygon",
multi: true
}
);
var edit = new OpenLayers.Control.ModifyFeature(wfs, {
title: "Modify Feature",
displayClass: "olControlModifyFeature"
});
var del = new DeleteFeature(wfs, {title: "Delete Feature"});
var save = new OpenLayers.Control.Button({
title: "Save Changes",
trigger: function() {
if(edit.feature) {
edit.selectControl.unselectAll();
}
saveStrategy.save();
},
displayClass: "olControlSaveFeatures"
});
function controlSelectFeature(wfs) {
feature_style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
feature_style.fillColor = "#FCFF6F";
feature_style.fillOpacity = 0.5;
options = {
hover: false,
onSelect: popUP,
selectStyle :feature_style
};
selection = new OpenLayers.Control.SelectFeature(wfs,
options);
map.addControl(selection);
selection.activate();
}
function popUP(e) {
if(typeof popup!='undefined'){
popup.destroy();
}
var htmlContent = "<b>Pays : "+e.attributes.idu+"</b><br />
<b><i>Region : "+e.attributes.supf+"</b></i>";
var size = new OpenLayers.Size(20,34);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
popup = new OpenLayers.Popup.FramedCloud(
e.fid,
e.geometry.getBounds().getCenterLonLat(),
null,
htmlContent,
null,
false,
null
);
map.addPopup(popup);
}
function featureStyle() {
feature_style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
feature_style.strokeWidth = 1;
feature_style.strokeColor = "#000000";
feature_style.fillColor = "#E11320";
feature_style.fillOpacity = 0.5;
return feature_style;
}
controlSelectFeature(wfs);
panel.addControls([ selection,navigate, save, del, edit, draw]);
panel.defaultControl = navigate;
map.addControl(panel);
map.zoomToMaxExtent();
}
<!--html with call to js file-->
<html>
<head>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="../lib/OpenLayers.js"></script>
<style>
#map {
width: 800px;
height: 500px;
float: left;
border: 1px solid #ccc;
}
#message {
position: relative;
left: 5px;
}
#docs {
float: left;
}
.customEditingToolbar {
float: right;
right: 0px;
height: 30px;
width: 200px;
}
.customEditingToolbar div {
float: right;
margin: 5px;
width: 24px;
height: 24px;
}
.olControlNavigationItemActive {
background-image:
url("../theme/default/img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -103px -23px;
}
.olControlNavigationItemInactive {
background-image:
url("../theme/default/img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -103px -0px;
}
.olControlDrawFeaturePolygonItemInactive {
background-image:
url("../theme/default/img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -26px 0px;
}
.olControlDrawFeaturePolygonItemActive {
background-image:
url("../theme/default/img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -26px -23px
;
}
.olControlModifyFeatureItemActive {
background-image: url(../theme/default/img/move_feature_on.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlModifyFeatureItemInactive {
background-image:
url(../theme/default/img/move_feature_off.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlDeleteFeatureItemActive {
background-image: url(../theme/default/img/remove_point_on.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlDeleteFeatureItemInactive {
background-image:
url(../theme/default/img/remove_point_off.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlSelectFeatureItemActive {
background-image:
url(../theme/default/img/remove_point_off.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlSelectFeatureItemInactive {
background-image:
url(../theme/default/img/remove_point_off.png);
background-repeat: no-repeat;
background-position: 0px 1px;
}
</style>
<script src="tinyows.js"></script>
</head>
<body onload="init()">
<h1 id="title">WFS Transaction Example, (TinyOWS ans
OpenLayers)</h1>
<div id="tags"></div>
<p id="shortdesc">
Shows the use of the WFS Transactions (WFS-T).
Parks of Osnabruck (Frida).
<br />
Base layers is OpenStreetMap from Omniscale WMS Server.
</p>
<div id="map"></div>
<div id="message"></div>
<div id="docs">
<p>
The WFS protocol allows for creation of new features and
reading, updating, or deleting of existing features.
</p>
<p>
Use the tools to create, modify, and delete (in order from
left
to right) features. Use the save tool (picture of a disk) to
save your changes. Use the navigation tool (hand) to stop
editing and use the mouse for map navigation.
</p>
<p>
See the <a href="tinyows_wfs-t.js"
target="_blank">wfs-protocol-transactions.js source</a> to see how this is
done.
</p>
</div>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/tinyows-users/attachments/20100713/1604e5f3/attachment-0001.htm
More information about the TinyOWS-users
mailing list