You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/11/13 01:16:35 UTC
svn commit: r1714145 [5/5] - in /sis/trunk: ./
core/sis-build-helper/src/main/java/org/apache/sis/internal/book/
core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/
core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-meta...
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -74,10 +74,38 @@ import org.junit.BeforeClass;
org.apache.sis.internal.jaxb.referencing.CC_GeneralOperationParameterTest.class,
org.apache.sis.internal.jaxb.referencing.CC_OperationParameterGroupTest.class,
+ // Coordinate Reference System components (except derived CRS).
+ org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
+ org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
+ org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
+ org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
+ org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
+ org.apache.sis.referencing.datum.DefaultTemporalDatumTest.class,
+ org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
+ org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
+ org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
+ org.apache.sis.referencing.cs.NormalizerTest.class,
+ org.apache.sis.referencing.cs.AbstractCSTest.class,
+ org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
+ org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
+ org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
+ org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
+ org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
+ org.apache.sis.referencing.cs.HardCodedCSTest.class,
+ org.apache.sis.referencing.crs.AbstractCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
+ org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
+
// Test transforms other than map projections.
org.apache.sis.referencing.operation.transform.CoordinateDomainTest.class,
org.apache.sis.referencing.operation.transform.IterationStrategyTest.class,
org.apache.sis.referencing.operation.transform.AbstractMathTransformTest.class,
+ org.apache.sis.referencing.operation.transform.ScaleTransformTest.class,
org.apache.sis.referencing.operation.transform.ProjectiveTransformTest.class,
org.apache.sis.referencing.operation.transform.LinearTransformTest.class,
org.apache.sis.referencing.operation.transform.ExponentialTransform1DTest.class,
@@ -88,15 +116,21 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.transform.TransferFunctionTest.class,
org.apache.sis.referencing.operation.transform.MathTransformsTest.class,
org.apache.sis.referencing.operation.transform.ContextualParametersTest.class,
-
- // Registration of map projections and other math transforms.
+ org.apache.sis.referencing.operation.transform.EllipsoidToCentricTransformTest.class,
+ org.apache.sis.referencing.operation.transform.MolodenskyTransformTest.class,
org.apache.sis.referencing.operation.DefaultFormulaTest.class,
org.apache.sis.referencing.operation.DefaultOperationMethodTest.class,
org.apache.sis.referencing.operation.AbstractSingleOperationTest.class,
- // Other test classes from the 'operation' package after the CRS tests below.
org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class,
+
+ // Registration of map projections and other math transforms.
org.apache.sis.internal.referencing.provider.AffineTest.class,
+ org.apache.sis.internal.referencing.provider.GeographicOffsetsTest.class,
+ org.apache.sis.internal.referencing.provider.Geographic3Dto2DTest.class,
org.apache.sis.internal.referencing.provider.LongitudeRotationTest.class,
+ org.apache.sis.internal.referencing.provider.GeocentricTranslationTest.class,
+ org.apache.sis.internal.referencing.provider.PositionVector7ParamTest.class,
+ org.apache.sis.internal.referencing.provider.CoordinateFrameRotationTest.class,
org.apache.sis.internal.referencing.provider.MapProjectionTest.class,
org.apache.sis.internal.referencing.provider.AllProvidersTest.class,
org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class,
@@ -112,32 +146,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.operation.projection.PolarStereographicTest.class,
org.apache.sis.referencing.operation.projection.ObliqueStereographicTest.class,
- // Coordinate Reference System components.
- org.apache.sis.referencing.datum.BursaWolfParametersTest.class,
- org.apache.sis.referencing.datum.TimeDependentBWPTest.class,
- org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
- org.apache.sis.referencing.datum.DefaultPrimeMeridianTest.class,
- org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
- org.apache.sis.referencing.datum.DefaultTemporalDatumTest.class,
- org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
- org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
- org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
- org.apache.sis.referencing.cs.NormalizerTest.class,
- org.apache.sis.referencing.cs.AbstractCSTest.class,
- org.apache.sis.referencing.cs.DefaultCartesianCSTest.class,
- org.apache.sis.referencing.cs.DefaultEllipsoidalCSTest.class,
- org.apache.sis.referencing.cs.DefaultSphericalCSTest.class,
- org.apache.sis.referencing.cs.DefaultCompoundCSTest.class,
- org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
- org.apache.sis.referencing.cs.HardCodedCSTest.class,
- org.apache.sis.referencing.crs.AbstractCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeodeticCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class,
- org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
- org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
- org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
- org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
- org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
+ // Coordinate operation and derived Coordinate Reference Systems (cyclic dependency).
org.apache.sis.referencing.operation.DefaultTransformationTest.class,
org.apache.sis.referencing.operation.DefaultConversionTest.class,
org.apache.sis.referencing.operation.SingleOperationMarshallingTest.class,
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListUID.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -171,6 +171,7 @@ public final class CodeListUID {
*
* @return The identifier to be given to the {@code CodeList.valueOf(…)} method.
*/
+ @Override
public String toString() {
String id = codeListValue;
if (id == null) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -75,6 +75,7 @@ import org.apache.sis.internal.jdk7.Obje
*
* @see Arrays
*/
+@SuppressWarnings("ReturnOfCollectionOrArrayField") // Array constants in this class are immutable empty arrays.
public final class ArraysExt extends Static {
/**
* An empty array of {@code double} primitive type.
@@ -399,6 +400,7 @@ public final class ArraysExt extends Sta
* @throws IllegalArgumentException If {@code length} is negative.
* @throws IndexOutOfBoundsException If {@code first} or {@code first+length} is out of array bounds.
*/
+ @SuppressWarnings("SuspiciousSystemArraycopy")
private static <T> T doRemove(final T array, final int first, final int length)
throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException
{
@@ -668,6 +670,7 @@ public final class ArraysExt extends Sta
* @throws IllegalArgumentException If {@code length} is negative.
* @throws IndexOutOfBoundsException If {@code first} or {@code first+length} is out of array bounds.
*/
+ @SuppressWarnings("SuspiciousSystemArraycopy")
private static <T> T doInsert(final T array, final int first, final int length)
throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException
{
@@ -961,6 +964,7 @@ public final class ArraysExt extends Sta
* @throws IllegalArgumentException If {@code length} is negative.
* @throws IndexOutOfBoundsException If {@code srcOff}, {@code srcOff+length} or {@code dstOff} is out of array bounds,
*/
+ @SuppressWarnings("SuspiciousSystemArraycopy")
private static <T> T doInsert(final T src, final int srcOff,
final T dst, final int dstOff, final int length)
throws NullArgumentException, IllegalArgumentException, IndexOutOfBoundsException
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -96,6 +96,11 @@ public final class Errors extends Indexe
public static final short CanNotComputeDerivative = 1;
/**
+ * Can not compute “{0}”.
+ */
+ public static final short CanNotCompute_1 = 201;
+
+ /**
* Can not concatenate transforms “{0}” and “{1}”.
*/
public static final short CanNotConcatenateTransforms_2 = 160;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -33,6 +33,7 @@ CanNotConcatenateTransforms_2 = Can
CanNotConnectTo_1 = Can not connect to \u201c{0}\u201d.
CanNotConvertFromType_2 = Can not convert from type \u2018{0}\u2019 to type \u2018{1}\u2019.
CanNotConvertValue_2 = Can not convert value \u201c{0}\u201d to type \u2018{1}\u2019.
+CanNotCompute_1 = Can not compute \u201c{0}\u201d.
CanNotComputeDerivative = Can not compute the derivative.
CanNotInstantiate_1 = Can not instantiate an object of type \u2018{0}\u2019.
CanNotMapAxisToDirection_2 = Can not map an axis from \u201c{0}\u201d to direction \u201c{1}\u201d.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -30,6 +30,7 @@ CanNotConcatenateTransforms_2 = Les
CanNotConnectTo_1 = Ne peut pas se connecter \u00e0 \u00ab\u202f{0}\u202f\u00bb.
CanNotConvertFromType_2 = Ne peut pas convertir du type \u2018{0}\u2019 vers le type \u2018{1}\u2019.
CanNotConvertValue_2 = La valeur \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre convertie vers le type \u2018{1}\u2019.
+CanNotCompute_1 = Ne peut pas calculer \u00ab\u202f{0}\u202f\u00bb.
CanNotComputeDerivative = La d\u00e9riv\u00e9 ne peut pas \u00eatre calcul\u00e9e.
CanNotInstantiate_1 = Ne peut pas cr\u00e9er un objet de type \u2018{0}\u2019.
CanNotMapAxisToDirection_2 = Aucun axe de \u00ab\u202f{0}\u202f\u00bb n\u2019a pu \u00eatre associ\u00e9 \u00e0 la direction \u00ab\u202f{1}\u202f\u00bb.
@@ -111,7 +112,7 @@ MismatchedArrayLengths = Les
MismatchedCRS = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es doit \u00eatre le m\u00eame pour tous les objets.
MismatchedDimension_2 = Les dimensions des objets ({0}D et {1}D) ne concordent pas.
MismatchedDimension_3 = L\u2019argument \u2018{0}\u2019 a {2} dimension{2,choice,1#|2#s}, alors qu\u2019on en attendait {1}.
-MismatchedMatrixSize_4 = Une matrice de taille de {0}\u00d7{1} \u00e9tait attendue mais la matrice donn\u00e9es est de taille {2}\u00d7{3}.
+MismatchedMatrixSize_4 = Une matrice de taille de {0}\u00d7{1} \u00e9tait attendue mais la matrice donn\u00e9e est de taille {2}\u00d7{3}.
MismatchedParameterDescriptor_1 = Le descripteur du param\u00e8tre \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
MismatchedPropertyType_1 = Le type de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
MismatchedTransformDimension_3 = La {0,choice,0#source|1#destination} de la transformation a {2} dimension{2,choice,1#|2#s}, alors qu\u2019on en attendait {1}.
Modified: sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml
URL: http://svn.apache.org/viewvc/sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml (original)
+++ sis/trunk/ide-project/NetBeans/nbproject/build-impl.xml Fri Nov 13 00:16:33 2015
@@ -209,7 +209,12 @@ is divided into following sections:
</not>
</and>
</condition>
- <property name="javac.fork" value="${jdkBug6558476}"/>
+ <condition else="false" property="javac.fork">
+ <or>
+ <istrue value="${jdkBug6558476}"/>
+ <istrue value="${javac.external.vm}"/>
+ </or>
+ </condition>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
@@ -235,6 +240,7 @@ is divided into following sections:
<condition else="" property="testng.debug.mode" value="-mixed">
<istrue value="${junit+testng.available}"/>
</condition>
+ <property name="java.failonerror" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
@@ -801,7 +807,7 @@ is divided into following sections:
<sequential>
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
- <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+ <java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
@@ -876,7 +882,7 @@ is divided into following sections:
<attribute default="${debug.classpath}" name="classpath"/>
<element name="customize" optional="true"/>
<sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
@@ -903,7 +909,7 @@ is divided into following sections:
<attribute default="jvm" name="jvm"/>
<element name="customize" optional="true"/>
<sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
Modified: sis/trunk/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/trunk/ide-project/NetBeans/nbproject/genfiles.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original)
+++ sis/trunk/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -3,6 +3,6 @@
build.xml.data.CRC32=58e6b21c
build.xml.script.CRC32=462eaba0
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
-nbproject/build-impl.xml.data.CRC32=8bd6b764
-nbproject/build-impl.xml.script.CRC32=fc0a5456
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
+nbproject/build-impl.xml.data.CRC32=21ae62d4
+nbproject/build-impl.xml.script.CRC32=e337b80c
+nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
Modified: sis/trunk/ide-project/NetBeans/nbproject/project.xml
URL: http://svn.apache.org/viewvc/sis/trunk/ide-project/NetBeans/nbproject/project.xml?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/trunk/ide-project/NetBeans/nbproject/project.xml Fri Nov 13 00:16:33 2015
@@ -56,7 +56,6 @@
<word>deserialization</word>
<word>deserialized</word>
<word>endianness</word>
- <word>excentricity</word>
<word>geoidal</word>
<word>hectopascals</word>
<word>initially</word>
Modified: sis/trunk/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] (original)
+++ sis/trunk/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -34,6 +34,11 @@ import static org.apache.sis.test.TestUt
* @module
*/
public final strictfp class DataIdentificationTest extends TestCase {
+ /**
+ * Tests marshalling and unmarshalling of a XML fragment.
+ *
+ * @throws JAXBException if an error occurred during (un)marshalling.
+ */
@Test
public void testMarshalling() throws JAXBException {
final String xml =
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -21,6 +21,8 @@ import java.io.IOException;
import java.nio.ByteOrder;
import java.text.MessageFormat;
import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.sis.feature.DefaultAttributeType;
import org.apache.sis.feature.DefaultFeatureType;
@@ -28,6 +30,7 @@ import org.apache.sis.internal.shapefile
import org.apache.sis.storage.shapefile.InvalidShapefileFormatException;
import org.apache.sis.storage.shapefile.ShapeTypeEnum;
import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.util.logging.Logging;
import com.esri.core.geometry.*;
@@ -141,7 +144,7 @@ public class ShapefileByteReader extends
MappedByteReader databaseReader = null;
try {
- databaseReader = new MappedByteReader(dbaseFile);
+ databaseReader = new MappedByteReader(dbaseFile, null);
databaseFieldsDescriptors = databaseReader.getFieldsDescriptors();
}
finally {
@@ -208,38 +211,123 @@ public class ShapefileByteReader extends
/**
* Load polygon feature.
* @param feature Feature to fill.
- * @throws InvalidShapefileFormatException if the polygon cannot be handled.
*/
- private void loadPolygonFeature(AbstractFeature feature) throws InvalidShapefileFormatException {
+ private void loadPolygonFeature(AbstractFeature feature) {
/* double xmin = */getByteBuffer().getDouble();
/* double ymin = */getByteBuffer().getDouble();
/* double xmax = */getByteBuffer().getDouble();
/* double ymax = */getByteBuffer().getDouble();
- int NumParts = getByteBuffer().getInt();
- int NumPoints = getByteBuffer().getInt();
+ int numParts = getByteBuffer().getInt();
+ int numPoints = getByteBuffer().getInt();
- if (NumParts > 1) {
- throw new InvalidShapefileFormatException("Polygons with multiple linear rings have not implemented yet.");
+ Polygon poly;
+
+ // Handle multiple polygon parts.
+ if (numParts > 1) {
+ Logger log = Logging.getLogger(ShapefileByteReader.class.getName());
+
+ if (log.isLoggable(Level.FINER)) {
+ String format = "Polygon with multiple linear rings encountered at position {0,number} with {1,number} parts.";
+ String message = MessageFormat.format(format, getByteBuffer().position(), numParts);
+ log.finer(message);
+ }
+
+ poly = readMultiplePolygonParts(numParts, numPoints);
+ }
+ else {
+ // Polygon with an unique part.
+ poly = readUniquePolygonPart(numPoints);
}
- // read the one part
- @SuppressWarnings("unused")
- int Part = getByteBuffer().getInt();
+ feature.setPropertyValue(GEOMETRY_NAME, poly);
+ }
+
+ /**
+ * Read a polygon that has a unique part.
+ * @param numPoints Number of the points of the polygon.
+ * @return Polygon.
+ */
+ @Deprecated // As soon as the readMultiplePolygonParts method proofs working well, this readUniquePolygonPart method can be removed and all calls be deferred to readMultiplePolygonParts.
+ private Polygon readUniquePolygonPart(int numPoints) {
+ int part = getByteBuffer().getInt();
+
Polygon poly = new Polygon();
// create a line from the points
double xpnt = getByteBuffer().getDouble();
double ypnt = getByteBuffer().getDouble();
- // Point oldpnt = new Point(xpnt, ypnt);
+
poly.startPath(xpnt, ypnt);
- for (int j = 0; j < NumPoints - 1; j++) {
+ for (int j = 0; j < numPoints - 1; j++) {
xpnt = getByteBuffer().getDouble();
ypnt = getByteBuffer().getDouble();
poly.lineTo(xpnt, ypnt);
}
- feature.setPropertyValue(GEOMETRY_NAME, poly);
+ return poly;
+ }
+
+ /**
+ * Read a polygon that has multiple parts.
+ * @param numParts Number of parts of this polygon.
+ * @param numPoints Total number of points of this polygon, all parts considered.
+ * @return a multiple part polygon.
+ */
+ private Polygon readMultiplePolygonParts(int numParts, int numPoints) {
+ /**
+ * From ESRI Specification :
+ * Parts : 0 5 (meaning : 0 designs the first v1, 5 designs the first v5 on the points list below).
+ * Points : v1 v2 v3 v4 v1 v5 v8 v7 v6 v5
+ *
+ * POSITION FIELD VALUE TYPE NUMBER ORDER
+ * Byte 0 Shape Type 5 Integer 1 Little
+ * Byte 4 Box Box Double 4 Little
+ * Byte 36 NumParts NumParts Integer 1 Little
+ * Byte 40 NumPoints NumPoints Integer 1 Little
+ * Byte 44 Parts Parts Integer NumParts Little
+ * Byte X Points Points Point NumPoints Little
+ */
+ int[] partsIndexes = new int[numParts];
+
+ // Read all the parts indexes (starting at byte 44).
+ for(int index=0; index < numParts; index ++) {
+ partsIndexes[index] = getByteBuffer().getInt();
+ }
+
+ // Read all the points.
+ double[] xPoints = new double[numPoints];
+ double[] yPoints = new double[numPoints];
+
+ for(int index=0; index < numPoints; index ++) {
+ xPoints[index] = getByteBuffer().getDouble();
+ yPoints[index] = getByteBuffer().getDouble();
+ }
+
+ // Create the polygon from the points.
+ Polygon poly = new Polygon();
+
+ // create a line from the points
+ for(int index=0; index < numPoints; index ++) {
+ // Check if this index is one that begins a new part.
+ boolean newPolygon = false;
+
+ for(int j=0; j < partsIndexes.length; j ++) {
+ if (partsIndexes[j] == index) {
+ newPolygon = true;
+ break;
+ }
+ }
+
+ if (newPolygon) {
+ poly.startPath(xPoints[index], yPoints[index]);
+ }
+ else {
+ poly.lineTo(xPoints[index], yPoints[index]);
+ }
+ }
+
+ return poly;
}
/**
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -95,6 +95,86 @@ public class ShapefileDescriptor {
}
/**
+ * Returns the version of the shapefile.
+ * @return Version.
+ */
+ public int getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Returns the ESRI shape type in the shapefile.
+ * @return Shape type.
+ */
+ public ShapeTypeEnum getShapeType() {
+ return this.shapeType;
+ }
+
+ /**
+ * Returns the X Min property.
+ * @return XMin.
+ */
+ public double getXmin() {
+ return this.xmin;
+ }
+
+ /**
+ * Returns the Y Min property.
+ * @return YMin.
+ */
+ public double getYmin() {
+ return this.ymin;
+ }
+
+ /**
+ * Returns the X Max property.
+ * @return XMax.
+ */
+ public double getXmax() {
+ return this.xmax;
+ }
+
+ /**
+ * Returns the Y Max property.
+ * @return YMax.
+ */
+ public double getYmax() {
+ return this.ymax;
+ }
+
+ /**
+ * Returns the Z Min property.
+ * @return ZMin.
+ */
+ public double getZmin() {
+ return this.zmin;
+ }
+
+ /**
+ * Returns the Z Max property.
+ * @return ZMax.
+ */
+ public double getZmax() {
+ return this.zmax;
+ }
+
+ /**
+ * Returns the M Min property.
+ * @return M min.
+ */
+ public double getMmin() {
+ return this.mmin;
+ }
+
+ /**
+ * Returns the M Max property.
+ * @return M Max.
+ */
+ public double getMmax(){
+ return this.mmax;
+ }
+
+ /**
* @see java.lang.Object#toString()
*/
@Override
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -138,11 +138,9 @@ abstract class AbstractDbase3ByteReader
* Convert the binary code page value of the Dbase 3 file to a recent Charset.
* @param codePageBinaryValue page code binary value.
* @return Charset.
- * @throws SQLInvalidDbaseFileFormatException if the binary value is not one of the standard values that the DBF file should carry : the Dbase 3
- * file might be corrupted.
* @throws UnsupportedCharsetException if the code page as no representation in recents Charset (legacy DOS or macintosh charsets).
*/
- protected Charset toCharset(byte codePageBinaryValue) throws SQLInvalidDbaseFileFormatException, UnsupportedCharsetException {
+ protected Charset toCharset(byte codePageBinaryValue) throws UnsupportedCharsetException {
// Attempt to find a known conversion.
String dbfCodePage = toCodePage(codePageBinaryValue);
@@ -156,21 +154,15 @@ abstract class AbstractDbase3ByteReader
case 0x97: dbfCodePage = "unsupported"; break; // eastern european macintosh
case 0x98: dbfCodePage = "unsupported"; break; // greek macintosh
case 0xC8: dbfCodePage = "unsupported"; break; // windows ee
- default: dbfCodePage = "invalid"; break;
+ default: dbfCodePage = "unsupported"; break;
}
}
assert dbfCodePage != null;
- // If the code page is invalid, the database itself has chances to be invalid too.
- if (dbfCodePage.equals("invalid")) {
- String message = format(Level.WARNING, "excp.illegal_codepage", codePageBinaryValue, getFile().getAbsolutePath());
- throw new SQLInvalidDbaseFileFormatException(message);
- }
-
// If the code page cannot find a match for a more recent Charset, we wont be able to handle this DBF.
if (dbfCodePage.equals("unsupported")) {
- String message = format(Level.WARNING, "excp.unsupported_codepage", dbfCodePage, getFile().getAbsolutePath());
+ String message = format(Level.WARNING, "excp.unsupported_codepage", codePageBinaryValue, getFile().getAbsolutePath());
throw new UnsupportedCharsetException(message);
}
@@ -254,6 +246,14 @@ abstract class AbstractDbase3ByteReader
return(knownConversions.get(pageCodeBinaryValue & 0xFF));
}
+
+ /**
+ * Set a charset.
+ * @param cs Charset.
+ */
+ public void setCharset(Charset cs) {
+ this.charset = cs;
+ }
/**
* Return a date from a byte array.
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -16,13 +16,15 @@
*/
package org.apache.sis.internal.shapefile.jdbc;
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.util.Properties;
+import java.util.logging.Logger;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
-import org.apache.sis.internal.system.*;
+import org.apache.sis.internal.system.Modules;
// Branch-dependent imports
import org.apache.sis.internal.jdk7.Objects;
@@ -64,7 +66,7 @@ public class DBFDriver extends AbstractJ
* Attempts to make a database connection to the given filename.
*
* @param url The path to a {@code .dbf} file.
- * @param info Ignored in current implementation.
+ * @param info Properties to ask for special features, behavior, or compatibility.
* @return A connection to the given DBF file.
* @throws SQLInvalidDbaseFileFormatException if the database file format is invalid.
* @throws SQLDbaseFileNotFoundException if the database file doesn't exist.
@@ -72,11 +74,10 @@ public class DBFDriver extends AbstractJ
*/
@Override
@SuppressWarnings("resource") // the function opens a connection.
- public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
+ public Connection connect(final String url, Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
Objects.requireNonNull(url, "the DBase3 url cannot be null");
File file = new File(url);
-
- return new DBFConnection(file, new MappedByteReader(file));
+ return new DBFConnection(file, new MappedByteReader(file, info));
}
/**
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -114,5 +114,5 @@ public interface Dbase3ByteReader {
* Read the next row as a set of objects.
* @return Map of field name / object value.
*/
- public Map<String, Object> readNextRowAsObjects();
+ public Map<String, byte[]> readNextRowAsObjects();
}
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -19,6 +19,8 @@ package org.apache.sis.internal.shapefil
import java.io.File;
import java.nio.BufferUnderflowException;
import java.nio.ByteOrder;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
import java.util.*;
import java.util.logging.Level;
@@ -39,14 +41,31 @@ public class MappedByteReader extends Ab
/** List of field descriptors. */
private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<DBase3FieldDescriptor>();
+ /** Connection properties. */
+ private Properties info;
+
/**
* Construct a mapped byte reader on a file.
* @param dbase3File File.
+ * @param connectionInfos Connection properties, maybe null.
* @throws SQLInvalidDbaseFileFormatException if the database seems to be invalid.
* @throws SQLDbaseFileNotFoundException if the Dbase file has not been found.
*/
- public MappedByteReader(File dbase3File) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
+ public MappedByteReader(File dbase3File, Properties connectionInfos) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
super(dbase3File);
+ this.info = connectionInfos;
+
+ // React to special features asked.
+ if (info != null) {
+ // Sometimes, DBF files have a wrong charset, or more often : none, and you have to specify it.
+ String recordCharset = (String)info.get("record_charset");
+
+ if (recordCharset != null) {
+ Charset cs = Charset.forName(recordCharset);
+ setCharset(cs);
+ }
+ }
+
loadDescriptor();
}
@@ -81,7 +100,26 @@ public class MappedByteReader extends Ab
*/
@Override
public boolean nextRowAvailable() {
- return getByteBuffer().hasRemaining();
+ // 1) Check for remaining bytes.
+ if (getByteBuffer().hasRemaining() == false) {
+ return false;
+ }
+
+ // 2) Check that the immediate next byte read isn't the EOF signal.
+ byte eofCheck = getByteBuffer().get();
+
+ boolean isEOF = (eofCheck == 0x1A);
+ this.log(Level.FINER, "log.delete_status", rowNum, eofCheck, isEOF ? "EOF" : "Active");
+
+ if (eofCheck == 0x1A) {
+ return false;
+ }
+ else {
+ // Return one byte back.
+ int position = getByteBuffer().position();
+ getByteBuffer().position(position-1);
+ return true;
+ }
}
/**
@@ -89,24 +127,36 @@ public class MappedByteReader extends Ab
* @return Map of field name / object value.
*/
@Override
- public Map<String, Object> readNextRowAsObjects() {
+ public Map<String, byte[]> readNextRowAsObjects() {
// TODO: ignore deleted records
/* byte isDeleted = */ getByteBuffer().get(); // denotes whether deleted or current
- // read first part of record
- HashMap<String, Object> fieldsValues = new HashMap<String,Object>();
+ // read first part of record
+ HashMap<String, byte[]> fieldsValues = new HashMap<String, byte[]>();
for (DBase3FieldDescriptor fd : fieldsDescriptors) {
byte[] data = new byte[fd.getLength()];
getByteBuffer().get(data);
+ // Trim the bytes right.
int length = data.length;
+
while (length != 0 && data[length - 1] <= ' ') {
length--;
}
- String value = new String(data, 0, length);
- fieldsValues.put(fd.getName(), value);
+ if (length != data.length) {
+ byte[] dataTrimmed = new byte[length];
+
+ for(int index=0; index < length; index ++) {
+ dataTrimmed[index] = data[index];
+ }
+
+ fieldsValues.put(fd.getName(), dataTrimmed);
+ }
+ else {
+ fieldsValues.put(fd.getName(), data);
+ }
}
rowNum ++;
@@ -137,7 +187,19 @@ public class MappedByteReader extends Ab
// Translate code page value to a known charset.
this.codePage = getByteBuffer().get();
- this.charset = toCharset(this.codePage);
+
+ if (this.charset == null) {
+ try {
+ this.charset = toCharset(this.codePage);
+ }
+ catch(UnsupportedCharsetException e) {
+ // Warn the caller that he will have to perform is own conversions.
+ format(Level.WARNING, "log.no_valid_charset", getFile().getAbsolutePath(), e.getMessage());
+ }
+ }
+ else {
+ format(Level.INFO, "log.record_charset", this.charset.name());
+ }
getByteBuffer().get(reservedFiller2);
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -314,9 +314,9 @@ public class DBFConnection extends Abstr
/**
* Read the next row as a set of objects.
- * @return Map of field name / object value.
+ * @return Map of field name / object value, or null if EoF has been encountered.
*/
- public Map<String, Object> readNextRowAsObjects() {
+ public Map<String, byte[]> readNextRowAsObjects() {
return byteReader.readNextRowAsObjects();
}
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -44,14 +44,11 @@ import org.apache.sis.internal.jdk8.Func
*/
public class DBFRecordBasedResultSet extends DBFResultSet {
/** The current record. */
- private Map<String, Object> record;
+ private Map<String, byte[]> record;
/** Condition of where clause (currently, only one is handled). */
private ConditionalClauseResolver singleConditionOfWhereClause;
- /** UTF-8 charset. */
- private static Charset UTF8 = Charset.forName("UTF-8");
-
/**
* Constructs a result set.
* @param stmt Parent statement.
@@ -471,35 +468,27 @@ public class DBFRecordBasedResultSet ext
assertNotClosed();
getFieldDesc(columnLabel, sql); // Ensure that the field queried exists, else a null value here can be interpreted as "not existing" or "has a null value".
- String withoutCharset = (String)record.get(columnLabel);
+ byte[] bytes = record.get(columnLabel);
- if (withoutCharset == null) {
+ if (bytes == null) {
wasNull = true;
- return withoutCharset;
+ return null;
}
else {
wasNull = false;
}
- // If a non null value has been readed, convert it to the wished Charset.
+ // If a non null value has been readed, convert it to the wished Charset (provided one has been given).
DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection();
- String withDatabaseCharset = new String(withoutCharset.getBytes(), cnt.getCharset());
- log(Level.FINER, "log.string_field_charset", columnLabel, withoutCharset, withDatabaseCharset, cnt.getCharset());
-
- // Because the Database is old (end of 1980's), it has not been made to support UTF-8 encoding.
- // But must users of DBase 3 don't know this, and sometimes a String field may carry such characters.
- // Attempt to determine if the string could be an UTF-8 String instead.
- String withUtf8Encoding = new String(withoutCharset.getBytes(), UTF8);
-
- // If conversion contains a not convertible character, it's not an UTF-8 string.
- // If the UTF-8 string is shorter than the one that would have given the database charset, it's a good sign : it has chances to be better.
- boolean unsureResult = withUtf8Encoding.indexOf('\ufffd') != -1 || withUtf8Encoding.length() >= withDatabaseCharset.length();
-
- if (unsureResult)
- return withDatabaseCharset;
+ Charset charset = cnt.getCharset();
+
+ if (charset == null) {
+ return new String(bytes);
+ }
else {
- log(Level.FINER, "log.string_field_charset", columnLabel, withoutCharset, withUtf8Encoding, UTF8);
- return withUtf8Encoding;
+ String withDatabaseCharset = new String(bytes, charset);
+ log(Level.FINER, "log.string_field_charset", columnLabel, withDatabaseCharset, charset);
+ return withDatabaseCharset;
}
}
@@ -598,8 +587,8 @@ public class DBFRecordBasedResultSet ext
DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql);
try {
- String textValue = (String)record.get(columnLabel);
-
+ String textValue = getString(columnLabel);
+
if (textValue == null) {
return null;
}
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -21,10 +21,12 @@ import java.io.InputStream;
import java.sql.SQLFeatureNotSupportedException;
import java.text.DecimalFormat;
import java.text.MessageFormat;
+import java.util.List;
import org.apache.sis.feature.DefaultFeatureType;
import org.apache.sis.internal.shapefile.SQLShapefileNotFoundException;
import org.apache.sis.internal.shapefile.ShapefileByteReader;
+import org.apache.sis.internal.shapefile.ShapefileDescriptor;
import org.apache.sis.internal.shapefile.jdbc.*;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
@@ -170,6 +172,33 @@ public class InputFeatureStream extends
}
/**
+ * Return the features type.
+ * @return Features type.
+ */
+ public DefaultFeatureType getFeaturesType()
+ {
+ return this.featuresType;
+ }
+
+ /**
+ * Returns the shapefile descriptor.
+ * @return Shapefile descriptor.
+ */
+ public ShapefileDescriptor getShapefileDescriptor()
+ {
+ return this.shapefileReader.getShapefileDescriptor();
+ }
+
+ /**
+ * Returns the database fields descriptors.
+ * @return List of fields descriptors.
+ */
+ public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors()
+ {
+ return this.shapefileReader.getFieldsDescriptors();
+ }
+
+ /**
* Read next feature responding to the SQL query.
* @return Feature, null if no more feature is available.
* @throws SQLNotNumericException if a field expected numeric isn't.
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -17,10 +17,12 @@
package org.apache.sis.storage.shapefile;
import java.io.File;
-
-// Branch-dependent imports
+import java.util.List;
import org.apache.sis.internal.jdk7.Objects;
+import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.internal.shapefile.ShapefileDescriptor;
+import org.apache.sis.internal.shapefile.jdbc.DBase3FieldDescriptor;
/**
* Provides a ShapeFile Reader.
@@ -40,6 +42,15 @@ public class ShapeFile {
/** Database file. */
private File databaseFile;
+ /** Type of the features contained in this shapefile. */
+ private DefaultFeatureType featuresType;
+
+ /** Shapefile descriptor. */
+ private ShapefileDescriptor shapefileDescriptor;
+
+ /** Database field descriptors. */
+ private List<DBase3FieldDescriptor> databaseFieldsDescriptors;
+
/**
* Construct a Shapefile from a file.
* @param shpfile file to read.
@@ -56,6 +67,30 @@ public class ShapeFile {
}
/**
+ * Return the default feature type.
+ * @return Feature type.
+ */
+ public DefaultFeatureType getFeaturesType() {
+ return this.featuresType;
+ }
+
+ /**
+ * Returns the shapefile descriptor.
+ * @return Shapefile descriptor.
+ */
+ public ShapefileDescriptor getShapefileDescriptor() {
+ return this.shapefileDescriptor;
+ }
+
+ /**
+ * Returns the database fields descriptors.
+ * @return List of fields descriptors.
+ */
+ public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
+ return this.databaseFieldsDescriptors;
+ }
+
+ /**
* Find features corresponding to an SQL request SELECT * FROM database.
* @return Features
* @throws DbaseFileNotFoundException if the database file has not been found.
@@ -64,6 +99,25 @@ public class ShapeFile {
* @throws InvalidShapefileFormatException if the shapefile format is invalid.
*/
public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException {
- return new InputFeatureStream(shapeFile, databaseFile);
+ InputFeatureStream is = new InputFeatureStream(shapeFile, databaseFile);
+ this.featuresType = is.getFeaturesType();
+ this.shapefileDescriptor = is.getShapefileDescriptor();
+ this.databaseFieldsDescriptors = is.getDatabaseFieldsDescriptors();
+ return is;
+ }
+
+ /**
+ * Load shapefile descriptors : features types, shapefileDescriptor, database field descriptors :
+ * this is also automatically done when executing a query on it, by findAll.
+ * @throws DbaseFileNotFoundException if the database file has not been found.
+ * @throws ShapefileNotFoundException if the shapefile has not been found.
+ * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+ * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+ */
+ public void loadDescriptors() throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
+ // Doing an simple query will init the internal descriptors.
+ // It prepares a SELECT * FROM <DBase> but don't read a record by itself.
+ InputFeatureStream is = findAll();
+ is.close();
}
}
Modified: sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties [ISO-8859-1] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -13,3 +13,18 @@ excp.illegal_column_index=Illegal column
#1 : SQL Query that was attempted but failed.
#2 : Database name.
excp.no_such_column_in_resultset=There is no ''{0}'' column in this SQL query ''{1}'' on database {2}.
+
+# Log : status of deletion of a record.
+#0 : Record number.
+#1 : Byte status.
+#2 : Meaning of this status.
+log.delete_status=rownum {0,number} : record byte status is {1}, meaning : {2}.
+
+# Log : no valid charset found on DBase file. None will be used.
+#0 : Database name.
+#1 : Error message received that explains the problem.
+log.no_valid_charset=No valid charset has been found on this {0} file : (error message : ''{1}'') and ResultSet.getString(...) methods will provide characters as they are. Reader might have to perform his own conversions.
+
+# Log : A given charset overrides the Dbase file one.
+#0 : Overriding charset.
+log.record_charset=A given record charset ''{0}'' has been set from the connection and will override the Dbase file one.
Modified: sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -13,3 +13,18 @@ excp.illegal_column_index=Index de colon
#1: SQL Query that was attempted but failed.
#2: Database name.
excp.no_such_column_in_resultset=Il n''y a pas de colonne ''{0}'' dans cette requête SQL ''{1}'' sur la base de données {2}.
+
+# Log : status of deletion of a record.
+#0 : Record number.
+#1 : Byte status.
+#2 : Meaning of this status.
+log.delete_status=rownum {0,number} : l''octet de statut d''enregistrement vaut {1}, signifiant : {2}.
+
+# Log : no valid charset found on DBase file. None will be used.
+#0 : Database name.
+#1 : Error message received that explains the problem.
+log.no_valid_charset=Aucun jeu de caractères valide n''a été trouvé dans le fichier {0} : (message d''erreur : ''{1}'') et les méthodes ResultSet.getString(...) vont fournir les caractères comme ils sont. Le lecteur pourra devoir réaliser ses propres conversions.
+
+# Log : A given charset overrides the Dbase file one.
+#0 : Overriding charset.
+log.record_charset=Un charset ''{0}'' a été défini dans la connection et va remplacer celui du fichier DBase.
Modified: sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -23,6 +23,6 @@ excp.no_more_results=The result set has
# Log : a string value has been converted with a charset.
#0 : Field name.
-#1 : Field original database value.
-#2 : Field value after being converted with the charset.
-log.string_field_charset=String field name ''{0}'', value ''{1}'' changed to ''{2}'' using charset {3}.
+#1 : Field value after being converted with the charset.
+#2 : Charset used.
+log.string_field_charset=String field name ''{0}'' bytes values converted to ''{1}'' using charset {2}.
Modified: sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] Fri Nov 13 00:16:33 2015
@@ -23,7 +23,6 @@ excp.no_more_results=Le ResultSet n''a p
# Log : a string value has been converted with a charset.
#0 : Field name.
-#1 : Field original database value.
-#2 : Field value after being converted with the charset.
-log.string_field_charset=String field name ''{0}'', value ''{1}'' changed to ''{2}'' using charset {3}.
-
+#1 : Field value after being converted with the charset.
+#2 : Charset used.
+log.string_field_charset=Les octets du champ de nom ''{0}'' ont été converties en ''{1}'' en utilisant le jeu de caractères {2}.
Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -17,6 +17,7 @@
package org.apache.sis.internal.shapefile.jdbc;
import java.sql.*;
+import java.util.Properties;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.test.DependsOnMethod;
@@ -44,6 +45,25 @@ public class DBFConnectionTest extends A
assertFalse("Connection should be opened", connection.isClosed());
assertTrue ("Connection should be valid", connection.isValid(0));
+ connection.close();
+ assertTrue ("Connection should be closed", connection.isClosed());
+ assertFalse("Connection should no more be valid", connection.isValid(0));
+ }
+
+ /**
+ * Open and close a connection.
+ * @throws SQLException if an error occurred while opening the database.
+ */
+ @Test
+ public void openCloseConnectionWithAnotherCharset() throws SQLException {
+ Properties info = new Properties();
+ info.put("record_charset", "UTF-8");
+
+ final Driver driver = new DBFDriver();
+ final Connection connection = driver.connect(dbfFile.getAbsolutePath(), info);
+ assertFalse("Connection should be opened", connection.isClosed());
+ assertTrue ("Connection should be valid", connection.isValid(0));
+
connection.close();
assertTrue ("Connection should be closed", connection.isClosed());
assertFalse("Connection should no more be valid", connection.isValid(0));
Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1714145&r1=1714144&r2=1714145&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Fri Nov 13 00:16:33 2015
@@ -16,8 +16,12 @@
*/
package org.apache.sis.storage.shapefile;
+import static org.junit.Assert.assertNotNull;
+
import java.io.File;
import java.net.URISyntaxException;
+import java.text.MessageFormat;
+import java.util.logging.Logger;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.TestCase;
@@ -77,6 +81,31 @@ public final strictfp class ShapeFileTes
readAll(shp);
}
+ /**
+ * Test loading of shapefile descriptors.
+ * @throws URISyntaxException if the resource name is incorrect.
+ * @throws DataStoreException if a general file reading trouble occurs.
+ */
+ @Test
+ public void testDescriptors() throws URISyntaxException, DataStoreException {
+ Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
+
+ ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
+ shp.loadDescriptors();
+
+ assertNotNull("The features type of the shapefile should have been set.", shp.getFeaturesType());
+ log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp features type : {0}", shp.getFeaturesType()));
+
+ assertNotNull("The shapefile descriptor of the shapefile should have been set.", shp.getShapefileDescriptor());
+ log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp shapefile descriptor : {0}", shp.getShapefileDescriptor()));
+
+ assertNotNull("The DBase III fields descriptors of the shapefile should have been set.", shp.getDatabaseFieldsDescriptors());
+ log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp DBase fields descriptors : {0}", shp.getDatabaseFieldsDescriptors()));
+
+ // Loading of the descriptor shall not prevent the shapefile from being red again.
+ readAll(shp);
+ }
+
/**
* Read all the shapefile content.
* @param shp Shapefile to read.