Hello Marc
Could you create a JIRA task [1] with the test case attached? For the
92-Hauts-de-Seine.shp.tar.gz test file, is the OpenStreet map license
compatible with the Apache 2 license? If not, we can use the file for
debugging but can not commit it to the SVN.
I will try to re-arrange the test in a way that doesn't use shapefile,
so we can both avoid licensing issue (if any) and move the test to
sis-feature module. I may take a few days since I'm travelling this week...
Martin
[1] https://issues.apache.org/jira/browse/SIS
Le 29/09/14 07:28, Marc Le Bihan a écrit :
> Ok, I have the Unit Test showing two problems, but I can't commit it
> at the moment.
> What the way to push them ? I think you have to set some rights for me
> first ?
>
> Here is the unit test I added in the sis-shapefile project (in the
> branch JDK 8 I'm using at the moment) :
>
> package org.apache.sis.storage.shapefile;
>
> import static org.junit.Assert.*;
>
> import java.io.*;
>
> import org.apache.sis.storage.*;
> import org.junit.*;
> import org.opengis.feature.*;
> import org.opengis.test.*;
>
> /**
> * Issues with features.
> * @author Marc LE BIHAN
> */
> public class IssuesWithFeaturesTest extends TestCase
> {
> /**
> * Issue : the first property red by DenseFeature is null.
> * @throws DataStoreException if unable to find or read the shapefile.
> * @throws IOException if unable to find or read the shapefile.
> */
> @Test public void issueFirstPropertyNull() throws IOException,
> DataStoreException {
> ShapeFile shapefile = new
> ShapeFile("src/test/resources/org/apache/sis/storage/shapefile/92-Hauts-de-Seine.shp");
>
> Feature feature =
> shapefile.FeatureMap.values().iterator().next(); // The shapefile has
> 36 features, take the first one.
> String city =
> (String)feature.getProperty("COMMUNE\0\0\0\0").getValue();
> String refInsee =
> (String)feature.getProperty("REF_INSEE\0\0").getValue();
> String zipCode =
> (String)feature.getProperty("CODE_POSTA\0").getValue();
>
> // The first feature property you read (city here) will return a
> null value.
> assertNotNull("The city should have an INSEE reference.", refInsee);
> assertNotNull("The city should have a zip code.", zipCode);
> assertNotNull("The city should have a name.", city);
> }
>
> /**
> * Issue : when features are loaded from a Shapefile, the DBF file
> may load its properties with fields padded oddly.
> * When comes the times to query the feature content, the
> getProperty(..) find nothing if the name is not padded.
> * @throws DataStoreException if unable to find or read the shapefile.
> * @throws IOException if unable to find or read the shapefile.
> */
> @Test public void featureIsTrickedByZerosChar() throws IOException,
> DataStoreException
> {
> ShapeFile shapefile = new
> ShapeFile("src/test/resources/org/apache/sis/storage/shapefile/92-Hauts-de-Seine.shp");
>
> Feature feature =
> shapefile.FeatureMap.values().iterator().next(); // The shapefile has
> 36 features, take the first one.
> feature.getProperty("COMMUNE\0\0\0\0"); // The field name
> currently set in the DBF.
> feature.getProperty("COMMUNE"); // fails because the DBF
> describes this field as "COMMUNE\0\0\0\0".
> }
> }
>
> I added for test resources the shapefile contained in this
> Openstreetmap tar.gz :
> http://export.openstreetmap.fr/contours-administratifs/communes/92-Hauts-de-Seine.shp.tar.gz
>
> Regards,
>
> Marc.