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 2016/02/24 11:47:15 UTC
svn commit: r1732067 - in /sis/branches/JDK8:
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-utility/src/main/java/org/apache/sis/util/
storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/
storage/sis-stora...
Author: desruisseaux
Date: Wed Feb 24 10:47:15 2016
New Revision: 1732067
URL: http://svn.apache.org/viewvc?rev=1732067&view=rev
Log:
Add "application/wkt" as the MIME type of WKT strings.
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreProviderTest.java
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java?rev=1732067&r1=1732066&r2=1732067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] Wed Feb 24 10:47:15 2016
@@ -163,6 +163,7 @@ public final class WKTKeywords extends S
* Related to {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation}.
*/
public static final String
+ BoundCRS = "BoundCRS",
Method = "Method",
Formula = "Formula",
Projection = "Projection",
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java?rev=1732067&r1=1732066&r2=1732067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] Wed Feb 24 10:47:15 2016
@@ -63,8 +63,8 @@ public class Version implements CharSequ
public static final Version SIS = new Version(MAJOR_VERSION + "." + MINOR_VERSION + "-SNAPSHOT");
/**
- * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore}
- * implementations. New constants are likely to be added in any future SIS versions.
+ * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore} implementations.
+ * New constants are likely to be added in any future SIS versions.
*
* @see #valueOf(int[])
*/
@@ -127,7 +127,7 @@ public class Version implements CharSequ
final int major = components[0];
if (components.length == 1) {
if (major >= 1 && major <= CONSTANTS.length) {
- return CONSTANTS[major-1];
+ return CONSTANTS[major - 1];
} else {
version = new Version(Integer.toString(major));
}
Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java?rev=1732067&r1=1732066&r2=1732067&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] Wed Feb 24 10:47:15 2016
@@ -27,6 +27,7 @@ import org.apache.sis.storage.DataStoreE
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.ProbeResult;
import org.apache.sis.internal.metadata.WKTKeywords;
+import org.apache.sis.util.Version;
/**
@@ -39,6 +40,11 @@ import org.apache.sis.internal.metadata.
*/
public class StoreProvider extends DataStoreProvider {
/**
+ * The {@value} MIME type.
+ */
+ public static final String MIME_TYPE = "application/wkt";
+
+ /**
* The read-ahead limit when reading the WKT from a {@link Reader}.
*/
static final int READ_AHEAD_LIMIT = 2048;
@@ -77,6 +83,7 @@ public class StoreProvider extends DataS
s.add(WKTKeywords.ProjCRS);
s.add(WKTKeywords.ProjCS);
s.add(WKTKeywords.Fitted_CS);
+ s.add(WKTKeywords.BoundCRS);
return s;
}
@@ -177,14 +184,17 @@ public class StoreProvider extends DataS
}
/*
* At this point we got the first keyword. Change the case to match the one used in the KEYWORDS map,
- * then verify if the keyword that we found is one of the known WKT keywords.
+ * then verify if the keyword that we found is one of the known WKT keywords. Keywords with the "CRS"
+ * suffix are WKT 2 while keywords with the "CS" suffix are WKT 1.
*/
final int length = pos;
if (pos >= MIN_LENGTH) {
- keyword[ 0] &= ~0x20; // Make upper-case (valid only for characters in the a-z range).
+ int version = 1;
+ keyword[ 0] &= ~0x20; // Make upper-case (valid only for characters in the a-z range).
keyword[--pos] &= ~0x20;
if ((keyword[--pos] &= ~0x20) == 'R') {
keyword[--pos] &= ~0x20; // Make "CRS" suffix in upper case (otherwise, was "CS" suffix)
+ version = 2;
}
while (--pos != 0) {
if (keyword[pos] != '_') {
@@ -192,7 +202,7 @@ public class StoreProvider extends DataS
}
}
if (KEYWORDS.contains(String.valueOf(keyword, 0, length))) {
- return ProbeResult.SUPPORTED;
+ return new ProbeResult(true, MIME_TYPE, Version.valueOf(version));
}
}
return ProbeResult.UNSUPPORTED_STORAGE;
Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreProviderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreProviderTest.java?rev=1732067&r1=1732066&r2=1732067&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreProviderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreProviderTest.java [UTF-8] Wed Feb 24 10:47:15 2016
@@ -60,25 +60,29 @@ public final strictfp class StoreProvide
@Test
public void testProbeContentFromReader() throws DataStoreException {
final StoreProvider p = new StoreProvider();
- testProbeContentFromReader(true, p, StoreTest.WKT);
- testProbeContentFromReader(true, p, "GeodeticCRS[…]");
- testProbeContentFromReader(true, p, "GeodeticCRS(…)");
- testProbeContentFromReader(true, p, "Vert_CS[…]");
- testProbeContentFromReader(false, p, "DummyCS[…]");
- testProbeContentFromReader(true, p, " GeodeticCRS […]");
- testProbeContentFromReader(false, p, " DummyCS […]");
- testProbeContentFromReader(false, p, "Geodetic");
+ testProbeContentFromReader(true, 1, p, StoreTest.WKT);
+ testProbeContentFromReader(true, 2, p, "GeodeticCRS[…]");
+ testProbeContentFromReader(true, 2, p, "GeodeticCRS(…)");
+ testProbeContentFromReader(true, 1, p, "Vert_CS[…]");
+ testProbeContentFromReader(false, 1, p, "DummyCS[…]");
+ testProbeContentFromReader(true, 2, p, " GeodeticCRS […]");
+ testProbeContentFromReader(false, 1, p, " DummyCS […]");
+ testProbeContentFromReader(false, 0, p, "Geodetic");
}
/**
* Implementation of {@link #testProbeContentFromReader()}.
*/
- private static void testProbeContentFromReader(final boolean supported,
+ private static void testProbeContentFromReader(final boolean isSupported, final int version,
final StoreProvider p, final String wkt) throws DataStoreException
{
final StorageConnector c = new StorageConnector(new StringReader(wkt));
final ProbeResult r = p.probeContent(c);
c.closeAllExcept(null);
- assertEquals("isSupported()", supported, r.isSupported());
+ assertEquals("isSupported", isSupported, r.isSupported());
+ if (isSupported) {
+ assertEquals("mimeType", "application/wkt", r.getMimeType());
+ assertEquals("version", version, r.getVersion().getMajor());
+ }
}
}
Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java?rev=1732067&r1=1732066&r2=1732067&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java [UTF-8] Wed Feb 24 10:47:15 2016
@@ -46,7 +46,7 @@ public final strictfp class XMLStoreProv
final StorageConnector c = new StorageConnector(new StringReader(XMLStoreTest.XML));
final ProbeResult r = p.probeContent(c);
c.closeAllExcept(null);
- assertTrue ("isSupported()", r.isSupported());
- assertEquals("getMimeType()", "application/vnd.iso.19139+xml", r.getMimeType());
+ assertTrue ("isSupported", r.isSupported());
+ assertEquals("mimeType", "application/vnd.iso.19139+xml", r.getMimeType());
}
}