Hola,<br><br>Estoy intentando escribir shapefiles con gvSIG y me han salido bastantes dudas y problemas que he intentado aislar en el siguiente método main:<br><br><span style="font-family: courier new,monospace;">1     public static void main(String[] args) throws Exception {</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">2         new DefaultLibrariesInitializer().fullInitialize();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">3         DataManager manager = DALLocator.getDataManager();</span><br style="font-family: courier new,monospace;">

4 <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">5         EditableFeatureType type = new DefaultEditableFeatureType();</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">6         type.add(&quot;geom&quot;, 66).setGeometryType(Geometry.TYPES.POINT)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">7                 .setGeometrySubType(Geometry.SUBTYPES.GEOM2D)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">8                 .setObjectClass(Geometry.class);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">9         type.add(&quot;double&quot;, DataTypes.DOUBLE);</span><br style="font-family: courier new,monospace;">

10<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">11        NewFeatureStoreParameters destParams = (NewFeatureStoreParameters) manager</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">12                .createNewStoreParameters(&quot;FilesystemExplorer&quot;, &quot;Shape&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">13        destParams.setDynValue(&quot;shpfile&quot;, &quot;/tmp/mySHP.shp&quot;);</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">14        destParams.setDynValue(&quot;dbffile&quot;, &quot;/tmp/mySHP.dbf&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">15        destParams.setDynValue(&quot;shxfile&quot;, &quot;/tmp/mySHP.shx&quot;);</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">16        destParams.setDynValue(&quot;crs&quot;, &quot;EPSG:23030&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">17        destParams.setDefaultFeatureType(type);</span><br style="font-family: courier new,monospace;">

18<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">19        manager.newStore(&quot;FilesystemExplorer&quot;, &quot;Shape&quot;, destParams, true);</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">20        FeatureStore store = (FeatureStore) manager.openStore(&quot;Shape&quot;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">21                destParams);</span><br style="font-family: courier new,monospace;">

22<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">23        store.edit();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">24        EditableFeature feature = store.createNewFeature().getEditable();</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">25        com.vividsolutions.jts.geom.Geometry g = new GeometryFactory()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">26                .createPoint(new Coordinate(0, 0));</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">27        Geometry fmapGeom = Converter.jtsToGeometry(g);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">28        feature.set(feature.getType().getDefaultGeometryAttributeIndex(),</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">29                fmapGeom);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">30        feature.set(&quot;double&quot;, 57.0);</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">31        store.insert(feature);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">32        store.finishEditing();</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">33    }</span><br><br>Como veis, trato de escribir un único registro en un shp que tiene dos campos: la geometría y un real. Mis dudas y problemas son:<br><ul><li>En la línea 6, para indicar que el tipo es geométrico pongo un 66, que es lo que he observado que me ha devuelto en otros casos al leer, pero no he encontrado en DataTypes (ni en otro sitio) una constante para identificar esto.</li>

<li>En la línea 27, Converter está marcado como @deprecated, pero no he encontrado ninguna alternativa para convertir una geometría de JTS a fmap.</li><li>Cuando intento abrir el shp que he escrito con geotools, me dice que &quot;ShapeType changed illegally from PointZ to Point&quot;.</li>

<li>Con gvSIG Desktop puedo abrir el shapefile, pero cuando lo muestro en una tabla, me aparece que el valor de &quot;double&quot; es 5.0. Si lo leo mediante código el resultado es el mismo. He probado a cambiar el valor del double a 34.0 así arbitrariamente y entonces se escribe un 3.0</li>

</ul>Pues eso es todo. Con respecto a las dos primeras cuestiones, la documentación que he mirado es la de la web [1][2]. Para las dos últimas, no tengo muy claro si es que no he utilizado la api correctamente, o es un bug o qué.<br>

<br>Gracias de antemano,<br>Víctor.<br><br>[1] <a href="http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/org.gvsig.fmap.dal">http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/org.gvsig.fmap.dal</a><br>
[2] <a href="http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/org.gvsig.fmap.geom">http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/org.gvsig.fmap.geom</a><br>