Hi list!
I'am using GeoServer as WFS-T in order to draw features in PostGIS tables. My Web Client is OpenLayers and I am trying to draw some points. My background is a G_HYBRID_MAP image.
I did as following:
* Created 3 empty postgis tables with MULTIPOINT, MULTILINESTRING,
MULTIPOLYGON geometry types:
* CREATE TABLE punto
(
gid serial NOT NULL,
id integer,
importo numeric,
nome character varying(80),
the_geom geometry,
CONSTRAINT punto_pkey PRIMARY KEY (gid),
CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
CONSTRAINT enforce_geotype_the_geom CHECK
(geometrytype(the_geom) = 'MULTIPOINT'::text OR the_geom IS
NULL),
CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = -1)
)
WITHOUT OIDS;
ALTER TABLE punto OWNER TO postgres;
* CREATE TABLE linea
(
gid serial NOT NULL,
id integer,
importo numeric,
nome character varying(80),
the_geom geometry,
CONSTRAINT linea_pkey PRIMARY KEY (gid),
CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
CONSTRAINT enforce_geotype_the_geom CHECK
(geometrytype(the_geom) = 'MULTILINESTRING'::text OR
the_geom IS NULL),
CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = -1)
)
WITHOUT OIDS;
ALTER TABLE linea OWNER TO postgres;
* CREATE TABLE poligono
(
gid serial NOT NULL,
id integer,
importo numeric,
nome character varying(80),
the_geom geometry,
CONSTRAINT poligono_pkey PRIMARY KEY (gid),
CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
CONSTRAINT enforce_geotype_the_geom CHECK
(geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom
IS NULL),
CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = -1)
)
WITHOUT OIDS;
ALTER TABLE poligono OWNER TO postgres;
* Created 3 empty features in GeoServer using SRS 4326
* Created the following html page:
o <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="/geoserver/style.css"
type="text/css" />
<style type="text/css">
body {
margin: 1em;
}
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="openlayers/OpenLayers.js"></script>
<script
src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ’></script>
<script type="text/javascript">
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
var map;
function init(){
map = new OpenLayers.Map('map');
var gsat = new OpenLayers.Layer.Google(
"Google Sattelite",
{type: G_HYBRID_MAP}
);
var punto = new OpenLayers.Layer.WFS(
"Punto",
"/geoserver/wfs",
{typename: 'topp:punto'},
{
typename: 'punto',
featureNS: 'http://www.openplans.org/topp’,
extractAttributes: false
}
);
map.addLayers([gsat, punto]);
var panel = new OpenLayers.Control.Panel(
{displayClass: 'olControlEditingToolbar'}
);
var drawPoint = new OpenLayers.Control.DrawFeature(
punto, OpenLayers.Handler.Point,
{displayClass: 'olControlDrawFeaturePoint'}
);
drawPoint.featureAdded = function(feature) {
feature.layer.eraseFeatures([feature]);
// cast to multipoint
feature.geometry = new
OpenLayers.Geometry.MultiPoint(
feature.geometry
);
feature.style.strokeColor = "#0000ff";
feature.state = OpenLayers.State.INSERT;
feature.layer.drawFeature(feature);
}
panel.addControls(
[new OpenLayers.Control.Navigation(), drawPoint]
);
map.addControl(panel);
map.addControl(new
OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(
new
OpenLayers.Bounds(12.454,36.591,15.590,38.351)
);
}
</script>
</head>
<body onload="init()">
<h3>GeoCaronte Demo</h3>
<a href="#" onclick="map.layers[1].commit();return
false">Salva Elementi Poligonali</a>
<div id="map"></div>
</body>
</html>
When I try to INSERT my edited points I have an error that depends by geometry types mismatch.
The error is:
<ServiceException>
java.lang.RuntimeException: Parsing failed for the_geom: java.lang.ClassCastException: com.vividsolutions
.jts.geom.MultiPoint cannot be cast to com.vividsolutions.jts.geom.Point
Parsing failed for the_geom: java.lang.ClassCastException: com.vividsolutions.jts.geom.MultiPoint cannot
be cast to com.vividsolutions.jts.geom.Point
com.vividsolutions.jts.geom.MultiPoint cannot be cast to com.vividsolutions.jts.geom.Point
</ServiceException></ServiceExceptionReport>
Why? How can i do?
PS: Is it right to use 4326 in order to edit new features, or I must use 900913 ?
Thanks a lot!
--
Ing. Fabio D'Ovidio
INOVA Open Solutions s.r.l.
Web : http://www.inovaos.it
Tel.: 081 197 57 600
mail: fabiodovidio@anonymised.com