[OpenLayers-Users] OpenLayers importing several GML files fromdifferent sources

Bart van den Eijnden bartvde at osgis.nl
Mon Nov 14 08:21:29 EST 2011


Hi,

try to use OpenLayers.Format.GML.v3 instead.

Best regards,
Bart

-- 
Bart van den Eijnden
OSGIS - http://osgis.nl

On Nov 14, 2011, at 12:04 PM, David Alda Fernandez de Lezea wrote:

> Hi again,
> 
> I think I found what was going on. The GML output got from gvSIG contains a parent tag inside featureMember tag named "Surface". This tag is not supported in GML parser from OpenLayers 2.9.1 (I'm using this version), I've been digging in the source code and found this issue in OpenLayers.Format.GML line 141. 
> 
> I don't know if this is an issue related with GML v3 schema or that OpenLayers 2.9 doesn't fully support this GML version. When exporting from gvSIG, I do it using GML version 3.1.2.
> 
> In this case I'm going to solve this by substituing "Surface" for "Polygon". Is there a more elegant way to do this?
> 
> Thanks in advance.
> 
> Regards,
> 
> Un saludo,
> 
> ··················································································
> 
> David Alda Fernández de Lezea
> Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
> 
> IKT
> Granja Modelo s/n · 01192 · Arkaute (Araba)
> 
> ··················································································
> Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
> ··················································································
> email: dalda at ikt.es                                web: www.ikt.es
> ··················································································
> 
> -----Mensaje original-----
> De: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] En nombre de David Alda Fernandez de Lezea
> Enviado el: lunes, 14 de noviembre de 2011 8:45
> Para: openlayers-users at lists.osgeo.org
> Asunto: [OpenLayers-Users] OpenLayers importing several GML files fromdifferent sources
> 
> 
> Hi list,
> 
> I'm trying to develope a GML file uploader which is supposed to upload different GML files from different sources, I mean, several GML created from different GIS software.
> 
> So far I manage to get some QGIS-created GML files into OpenLayers. But when I was trying to do the same with gvSIG, I couldn't get any geometry. The parsing process doesn't throw any error message. In fact, it seems that it reads the GML because while debugging with Firebug I can see that, although the geometry attribute is null, it has read the GML attributes, and they have values. It also has read the fid field correctly. I use this code.
> 
> 	var theParser = new OpenLayers.Format.GML();
> 	theParser.internalProjection = null;
> 	theParser.externalProjection = null;
> 	theParser.extractStyles = false;
> 	theParser.extractAttributes = true;
> 	var features = theParser.read(req);
> 
> XML that works fine
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <ogr:FeatureCollection
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://ogr.maptools.org/ prueba.xsd"
>     xmlns:ogr="http://ogr.maptools.org/"
>     xmlns:gml="http://www.opengis.net/gml">
>  <gml:boundedBy>
>    <gml:Box>
>      <gml:coord><gml:X>509296.3493197768</gml:X><gml:Y>4754836.958233111</gml:Y></gml:coord>
>      <gml:coord><gml:X>518092.0880311229</gml:X><gml:Y>4763261.318750359</gml:Y></gml:coord>
>    </gml:Box>
>  </gml:boundedBy>                      
>  <gml:featureMember>
>    <ogr:prueba fid="F0">
>      <ogr:geometryProperty>
> 	  <gml:Polygon>
> 	  <gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>510483.09779106994,4763261.3187503591 509759.18122358114,4762311.9199733241 509747.31373886816,4762264.4500344731 509759.18122358114,4761647.3408294003 509438.75913633197,4761599.8708905485 509296.34931977681,4762442.4623051668 510483.09779106994,4763261.3187503591</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
>      <ogr:Campo1></ogr:Campo1>
>      <ogr:Campo2></ogr:Campo2>
>      <ogr:Campo3></ogr:Campo3>
>      <ogr:Campo4></ogr:Campo4>
>      <ogr:Campo5></ogr:Campo5>
>      <ogr:Campo6></ogr:Campo6>
>      <ogr:Campo7></ogr:Campo7>
>    </ogr:prueba>
>  </gml:featureMember>
>  <gml:featureMember>
>    <ogr:prueba fid="F1">
>      <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>518092.08803112287,4754865.0112195052 518086.47743384406,4754858.1538228309 518068.39884261234,4754853.7900249474 518044.0862544041,4754850.0496267611 518014.16306891706,4754838.205032506 517987.35688191827,4754836.9582331106 517984.86328312766,4754859.4006222263 517999.20147617353,4754869.3750173887 518023.51406438177,4754878.726012853 518049.69685168291,4754883.0898107365 518072.76264049584,4754874.3622149695 518092.08803112287,4754865.0112195052</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
>      <ogr:Campo1></ogr:Campo1>
>      <ogr:Campo2></ogr:Campo2>
>      <ogr:Campo3></ogr:Campo3>
>      <ogr:Campo4></ogr:Campo4>
>      <ogr:Campo5></ogr:Campo5>
>      <ogr:Campo6></ogr:Campo6>
>      <ogr:Campo7></ogr:Campo7>
>    </ogr:prueba>
>  </gml:featureMember>
> </ogr:FeatureCollection>
> 
> XMl that doesn't load the geometry
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <gml:FeatureCollection
> xmlns:cit="http://www.gvsig.org/cit"  
> xmlns:gml="http://www.opengis.net/gml" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:schemaLocation="http://www.gvsig.org/cit cit.xsd">
> 	<gml:name>gestfore.shp</gml:name>
> 	<gml:boundedBy>
> 		<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#23030">
> 			<gml:coord><gml:X>509296.3493197768</gml:X><gml:Y>4754836.958233111</gml:Y><gml:Z>4754836.958233111</gml:Z></gml:coord>
> 			<gml:coord><gml:X>518092.08803112287</gml:X><gml:Y>4763261.318750359</gml:Y><gml:Z>4763261.318750359</gml:Z></gml:coord>
> 		</gml:Box>
> 	</gml:boundedBy>
> 	<gml:featureMember>
> 		<cit:FEATURE fid="2">
> 			<gml:Surface srsName="http://www.opengis.net/gml/srs/epsg.xml#23030">
> 				<gml:exterior>
> 					<gml:LinearRing>
> 					<gml:coordinates>510612.9302840919,4758505.035971242,0 510719.9951351402,4758592.026162719,0 510914.05017766514,4758672.324801005,0 511181.71230528585,4758779.389652054,0 511282.08560314355,4758632.175481862,0 511215.1700712384,4758458.195098909,0 511027.80658190395,4758190.532971288,0 510980.96570957033,4758183.841418098,0 510766.8360074738,4758357.821801051,0 510612.9302840919,4758505.035971242,0 510612.9302840919,4758505.035971242,0</gml:coordinates>
> 					</gml:LinearRing>
> 				</gml:exterior>
> 			</gml:Surface>
> 			<cit:Campo1>1</cit:Campo1>
> 			<cit:Campo2></cit:Campo2>
> 			<cit:Campo3></cit:Campo3>
> 			<cit:Campo4></cit:Campo4>
> 			<cit:Campo5></cit:Campo5>
> 			<cit:Campo6></cit:Campo6>
> 			<cit:Campo7></cit:Campo7>
> 		</cit:FEATURE>
> 	</gml:featureMember>
> </gml:FeatureCollection>
> 
> I've tried configuring many of the parser's optiones but without success. I know I'm close to the solution, but I'm really stucked.
> 
> Does anybody know what could be happening??
> 
> Thanks in advance.
> 
> Un saludo,
> 
> ··················································································
> 
> David Alda Fernández de Lezea
> Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
> 
> IKT
> Granja Modelo s/n · 01192 · Arkaute (Araba)
> 
> ··················································································
> Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
> ··················································································
> email: dalda at ikt.es                                web: www.ikt.es
> ··················································································
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111114/9ee142f5/attachment-0001.html


More information about the Users mailing list