Author: desruisseaux Date: Sat Jun 11 21:16:39 2016 New Revision: 1747935 URL: http://svn.apache.org/viewvc?rev=1747935&view=rev Log: Adjustment in OpenOffice function names and documentation. Add a TRANSFORM.ENVELOPPE(...) function. Text <-> angle conversions as matrix functions for more efficient conversions of large amout of values. Modified: sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/Transformer.java sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.idl sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.java sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/Referencing.xcu sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/org/apache/sis/openoffice/XReferencing.class sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/sis.rdb sis/branches/JDK8/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java Modified: sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java [UTF-8] (original) +++ sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/AnglePattern.java [UTF-8] Sat Jun 11 21:16:39 2016 @@ -58,6 +58,11 @@ final class AnglePattern { private byte type; /** + * If an error occurred during parsing, the first error. + */ + ParseException warning; + + /** * Converts the given argument to a pattern valid for {@link AngleFormat}. * * @param patternOrVoid the optional pattern argument from the OpenOffice formula. @@ -106,48 +111,67 @@ final class AnglePattern { } /** - * Parses the given angle. + * Parses the given angle. This function is typically invoked for parsing only one value. + * But it is nevertheless defined as a matrix function for more efficient conversions of + * a bulk of angles. * * @param text the angle to parse. * @param locale the expected locale of the text to parse. */ - double parse(final String text, final Locale locale) throws ParseException { - AngleFormat format = getAngleFormat(locale); - Angle angle; - try { - synchronized (format) { - angle = format.parse(text); - } - } catch (ParseException exception) { - // Parse failed. Try to parse as an unlocalized string. - format = getAngleFormat(Locale.ROOT); - try { - synchronized (format) { - angle = format.parse(text); + double[][] parse(final String[][] text, final Locale locale) { + final AngleFormat format = getAngleFormat(locale); + final double[][] value = new double[text.length][]; + synchronized (format) { + for (int j=0; j=0;) { sourcePt.ordinates[i] = (i < coords.length) ? coords[i] : 0; } @@ -169,6 +172,9 @@ final class Transformer { * we will report the failure for logging purpose, but only the first one since * all subsequent failures are likely to be the same one. */ + final double[] pad = new double[mt.getTargetDimensions()]; + Arrays.fill(pad, Double.NaN); + result[j] = pad; if (warning == null) { warning = exception; } @@ -177,4 +183,28 @@ final class Transformer { } return result; } + + /** + * Transforms the given envelope. + */ + final double[][] transformEnvelope(final double[][] points) throws TransformException { + final double[] min = new double[operation.getMathTransform().getSourceDimensions()]; + final double[] max = new double[min.length]; + Arrays.fill(min, Double.POSITIVE_INFINITY); + Arrays.fill(max, Double.NEGATIVE_INFINITY); + for (final double[] p : points) { + if (p != null) { // Paranoiac check. + for (int i=Math.min(min.length, p.length); --i >= 0;) { + final double v = p[i]; + if (v < min[i]) min[i] = v; + if (v > max[i]) max[i] = v; + } + } + } + final GeneralEnvelope result = Envelopes.transform(operation, new GeneralEnvelope(min, max)); + return new double[][] { + result.getLowerCorner().getCoordinate(), + result.getUpperCorner().getCoordinate() + }; + } } Modified: sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.idl URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.idl?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.idl [UTF-8] (original) +++ sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.idl [UTF-8] Sat Jun 11 21:16:39 2016 @@ -64,8 +64,8 @@ module org { [in] string sourceCRS, /// Authority code of the target coordinate reference system. [in] string targetCRS, - /// The source coordinates to transform. - [in] any points + /// An optional bounding box of source coordinates to transform. + [in] any areaOfInterest ) raises (com::sun::star::lang::IllegalArgumentException); /// Transforms a list of coordinates from source CRS to target CRS. @@ -78,20 +78,34 @@ module org { [in] sequence< sequence< double > > points ); + /// Transforms the envelope of given points from source CRS to target CRS. + sequence< sequence< double > > transformEnvelope( + /// Authority code of the source coordinate reference system. + [in] string sourceCRS, + /// Authority code of the target coordinate reference system. + [in] string targetCRS, + /// The source envelope to transform. + [in] sequence< sequence< double > > envelope + ); + /// Converts text in degrees-minutes-seconds to an angle in decimal degrees. - double parseAngle( + sequence< sequence< double > > parseAngle( /// The text to be converted to an angle. - [in] string text, + [in] sequence< sequence< string > > text, /// The text that describes the format (example: "D MM.m'"). - [in] any pattern + [in] any pattern, + /// The locale (example: "en", "fr"). + [in] any locale ) raises (com::sun::star::lang::IllegalArgumentException); /// Converts an angle to text according to a given format. - string formatAngle( + sequence< sequence< string > > formatAngle( /// The angle value (in decimal degrees) to be converted. - [in] double value, + [in] sequence< sequence< double > > value, /// The text that describes the format (example: "D MM.m'"). - [in] any pattern + [in] any pattern, + /// The locale (example: "en", "fr"). + [in] any locale ) raises (com::sun::star::lang::IllegalArgumentException); }; Modified: sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.java?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.java [UTF-8] (original) +++ sis/branches/JDK8/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/XReferencing.java [UTF-8] Sat Jun 11 21:16:39 2016 @@ -71,13 +71,13 @@ public interface XReferencing extends XI /** * Returns the accuracy of a transformation between two coordinate reference systems. * - * @param sourceCRS the authority code for the source coordinate reference system. - * @param targetCRS the authority code for the target coordinate reference system. - * @param points the coordinates to transform (for computing area of interest). + * @param sourceCRS the authority code for the source coordinate reference system. + * @param targetCRS the authority code for the target coordinate reference system. + * @param areaOfInterest an optional bounding box of source coordinates to transform. * @return the operation accuracy. * @throws IllegalArgumentException if {@code points} is not a {@code double[][]} value or void. */ - double getAccuracy(String sourceCRS, String targetCRS, Object points) throws IllegalArgumentException; + double getAccuracy(String sourceCRS, String targetCRS, Object areaOfInterest) throws IllegalArgumentException; /** * Transforms coordinates from the specified source CRS to the specified target CRS. @@ -85,20 +85,31 @@ public interface XReferencing extends XI * @param sourceCRS the authority code for the source coordinate reference system. * @param targetCRS the authority code for the target coordinate reference system. * @param points the coordinates to transform. - * @return The transformed coordinates. + * @return the transformed coordinates. */ double[][] transformPoints(String sourceCRS, String targetCRS, double[][] points); /** + * Transforms an envelope from the specified source CRS to the specified target CRS. + * + * @param sourceCRS the authority code for the source coordinate reference system. + * @param targetCRS the authority code for the target coordinate reference system. + * @param envelope points inside the envelope to transform. + * @return the transformed envelope. + */ + double[][] transformEnvelope(String sourceCRS, String targetCRS, double[][] envelope); + + /** * Converts text in degrees-minutes-seconds to an angle in decimal degrees. * See {@link org.apache.sis.measure.AngleFormat} for pattern description. * - * @param text the text to be converted to an angle. - * @param pattern an optional text that describes the format (example: "D°MM.m'"). + * @param text the text to be converted to an angle. + * @param pattern an optional text that describes the format (example: "D°MM.m'"). + * @param locale the convention to use (e.g. decimal separator symbol). * @return the angle parsed as a number. * @throws IllegalArgumentException if {@code pattern} is not a string value or void. */ - double parseAngle(String text, Object pattern) throws IllegalArgumentException; + double[][] parseAngle(String[][] text, Object pattern, Object locale) throws IllegalArgumentException; /** * Converts an angle to text according to a given format. This method uses the pattern @@ -109,10 +120,11 @@ public interface XReferencing extends XI *
  • If the pattern ends with N or S, then the angle is formatted as a latitude.
  • * * - * @param value the angle value (in decimal degrees) to be converted. - * @param pattern an optional text that describes the format (example: "D°MM.m'"). + * @param value the angle value (in decimal degrees) to be converted. + * @param pattern an optional text that describes the format (example: "D°MM.m'"). + * @param locale the convention to use (e.g. decimal separator symbol). * @return the angle formatted as a string. * @throws IllegalArgumentException if {@code pattern} is not a string value or void. */ - String formatAngle(double value, Object pattern) throws IllegalArgumentException; + String[][] formatAngle(double[][] value, Object pattern, Object locale) throws IllegalArgumentException; } Modified: sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/Referencing.xcu URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/Referencing.xcu?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/Referencing.xcu (original) +++ sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/Referencing.xcu Sat Jun 11 21:16:39 2016 @@ -28,11 +28,11 @@ CRS.NAME - CRS.NOM + NOM.SRS - Returns the name of an object identified by the given code. - Retourne le nom d’un objet identifié par le code donné. + Returns the name of an object identified by the given code. The object is usually, but not necessarily, a Coordinate Reference System (CRS). + Retourne le nom d’un objet identifié par le code donné. L’objet est habituellement, mais pas obligatoirement, un Système de Références Spatiales (SRS). Add-In @@ -54,11 +54,11 @@ CRS.AXIS - CRS.AXE + AXE.SRS - Returns the axis name for the specified dimension in a system identified by the given code. - Retourne le nom de l’axe à la dimension spécifiée dans un système identifié par le code donné. + Returns the axis name for the specified dimension in a Coordinate Reference System (CRS) identified by the given code. + Retourne le nom de l’axe à la dimension spécifiée dans un Système de Références Spatiales (SRS) identifié par le code donné. Add-In @@ -93,10 +93,8 @@ REGION.GEOGRAPHIQUE - Returns the domain as a geographic bounding box for an object identified by the given code. - The box is expressed by a 2×2 matrix with latitudes in the first column and longitudes in the second column. - Retourne sous forme de boîte englobante le domaine d’un objet identifié par le code donné. - La boîte est exprimée par une matrice 2×2 avec les latitudes dans la première colonne et les longitudes dans la seconde colonne. + Returns the domain as a geographic bounding box for an object identified by the given code. The box is expressed by a 2×2 matrix with latitudes in the first column and longitudes in the second column. + Retourne sous forme de boîte englobante le domaine d’un objet identifié par le code donné. La boîte est exprimée par une matrice 2×2 avec les latitudes dans la première colonne et les longitudes dans la seconde colonne. Add-In @@ -121,8 +119,8 @@ PRECISION.TRANSFORM - Returns the accuracy of a coordinate operation applied between two given reference systems. - Retourne la précision d’une opération sur les coordonnées effectuée entre les deux systèmes de référence donnés. + Returns the accuracy of a coordinate operation applied between two given Coordinate Reference Systems (CRS). In some cases, accuracy depends also on the geographic area of the points to transform. + Retourne la précision d’une opération sur les coordonnées effectuée entre les deux Systèmes de Références Spatiales (SRS) donnés. Dans certains cas, la précision dépend aussi de la région géographique contenant les points à transformer. Add-In @@ -135,7 +133,7 @@ Identifier of the source coordinate reference system. - Identifiant du système de référence des coordonnées sources. + Identifiant du système de références spatiales des coordonnées sources. @@ -145,17 +143,17 @@ Identifier of the target coordinate reference system. - Identifiant du système de référence des coordonnées destinations. + Identifiant du système de références spatiales des coordonnées destinations. - + - points - points + area + région - Coordinates of points to transform (optional). This information may affect parameters of the selected coordinate transformation. - Coordonnées des points à transformer (optionnel). Cette information peut influer les paramètres de la transformation choisie. + Bounding box of source points to transform. This is a matrix of at least two rows containing (in any order) the minimum and maximum values of all coordinates to transform. + Boîte englobante des points sources à transformer. C’est une matrice d’au moins deux lignes contenant (dans n’importe quel ordre) les valeurs minimales et maximales des coordonnées à transformer. @@ -167,8 +165,8 @@ TRANSFORM.POINTS - Transform coordinates from the given source CRS to the given target CRS. - Transforme des coordonnées à partir du CRS source donné vers le CRS destination donné. + Transform coordinates from the given source Coordinate Reference System (CRS) to the given target CRS. + Transforme des coordonnées à partir du Système de Références Spatiales (SRS) source donné vers le SRS destination donné. Add-In @@ -181,7 +179,7 @@ Identifier of the source coordinate reference system. - Identifiant du système de référence des coordonnées sources. + Identifiant du système de références spatiales des coordonnées sources. @@ -191,7 +189,7 @@ Identifier of the target coordinate reference system. - Identifiant du système de référence des coordonnées destinations. + Identifiant du système de références spatiales des coordonnées destinations. @@ -207,6 +205,52 @@ + + + TRANSFORM.ENVELOPE + TRANSFORM.ENVELOPPE + + + Transform the bounding box of given points from source Coordinate Reference System (CRS) to target CRS. + Transforme la boîte englobante des points donnés à partir du Système de Références Spatiales (SRS) source vers le SRS destination. + + + Add-In + + + + + source + source + + + Identifier of the source coordinate reference system. + Identifiant du système de références spatiales de l’enveloppe sources. + + + + + target + destination + + + Identifier of the target coordinate reference system. + Identifiant du système de références spatiales de l’enveloppe destinations. + + + + + envelope + enveloppe + + + Source envelope to transform. This is a matrix of at least two rows containing (in any order) the minimum and maximum values of the envelope to transform. + Boîte englobante des points sources à transformer. C’est une matrice d’au moins deux lignes contenant (dans n’importe quel ordre) les valeurs minimales et maximales de l’enveloppe à transformer. + + + + + VALUE.ANGLE @@ -236,8 +280,20 @@ modèle - An optional text that gives the angle pattern (example: D°MM.m’). - Un texte optionnel donnant le modèle des angles (exemple: D°MM.m’). + The angle format pattern (example: D°MM.m’). D is for degrees, M for minutes, S for seconds and . for the decimal separator. Upper-cases are for integer parts and lower-case are are the fractional part. Pattern can be optionally be suffixed by N or S for latitudes and by E or W for longitudes. + + Le modèle du format des angles (exemple: D°MM.m’). D est pour les degrés, M pour les minutes, S pour les secondes et . pour le séparateur décimal. Les majuscules sont pour la partie entière et les minuscules pour la partie fractionnaire de l'angle. Le modèle peut facultativement être suivit de N ou S pour les latitudes et E or W pour les longitudes. + + + + + + locale + langue + + + An optional language code for specifying the convention to use. For example “en” uses the dot as a decimal separator while “fr” uses coma. If unspecified, then conventions will be those of the default locale. + Un code de langue optionnel pour spécifier les conventions à utiliser. Par exemple « en » utilise le point comme séparateur décimal alors que « fr » utilise la virgule. Si non-spécifié, alors les conventions seront celles de la langue par défaut. @@ -272,8 +328,18 @@ modèle - An optional text that gives the angle pattern (example: D°MM.m’). - Un texte optionnel donnant le modèle des angles (exemple: D°MM.m’). + The angle format pattern (example: D°MM.m’). D is for degrees, M for minutes, S for seconds and . for the decimal separator. Upper-cases are for integer parts and lower-case are are the fractional part. Pattern can be optionally be suffixed by N or S for latitudes and by E or W for longitudes. + Le modèle du format des angles (exemple: D°MM.m’). D est pour les degrés, M pour les minutes, S pour les secondes et . pour le séparateur décimal. Les majuscules sont pour la partie entière et les minuscules pour la partie fractionnaire de l'angle. Le modèle peut facultativement être suivit de N ou S pour les latitudes et E or W pour les longitudes. + + + + + locale + langue + + + An optional language code for specifying the convention to use. For example “en” uses the dot as a decimal separator while “fr” uses coma. If unspecified, then conventions will be those of the default locale. + Un code de langue optionnel pour spécifier les conventions à utiliser. Par exemple « en » utilise le point comme séparateur décimal alors que « fr » utilise la virgule. Si non-spécifié, alors les conventions seront celles de la langue par défaut. Modified: sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/org/apache/sis/openoffice/XReferencing.class URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/org/apache/sis/openoffice/XReferencing.class?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== Binary files - no diff available. Modified: sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/sis.rdb URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/main/unopkg/sis.rdb?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== Binary files - no diff available. Modified: sis/branches/JDK8/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java [UTF-8] (original) +++ sis/branches/JDK8/application/sis-openoffice/src/test/java/org/apache/sis/openoffice/ReferencingFunctionsTest.java [UTF-8] Sat Jun 11 21:16:39 2016 @@ -150,15 +150,34 @@ public final strictfp class ReferencingF } /** + * Tests {@link ReferencingFunctions#transformEnvelope(String, String, double[][])}. + */ + @Test + public void testTransformEnvelope() { + final double[][] points = { + new double[] {30, 20, 4}, + new double[] {34, 17, -3}, + new double[] {27, -12, 12}, + new double[] {32, 23, -1} + }; + final double[][] result = { + new double[] {27, -12}, + new double[] {34, 23} + }; + TransformerTest.assertPointsEqual(result, + instance.transformEnvelope("EPSG:4979", "EPSG:4326", points), STRICT); + } + + /** * Tests {@link ReferencingFunctions#parseAngle(String, Object)}. * * @throws IllegalArgumentException if the pattern used by the test is not a string or void. */ @Test public void testParseAngle() throws IllegalArgumentException { - assertEquals(43.50, instance.parseAngle("43°30'", "D°MM.m'"), STRICT); - assertEquals(43.50, instance.parseAngle("4330", "DMM"), STRICT); - assertEquals(-3.25, instance.parseAngle("-3°15'", "D°MM.m'"), STRICT); + assertEquals(43.50, singleton(instance.parseAngle(new String[][] {{"43°30'"}}, "D°MM.m'", "en")), STRICT); + assertEquals(43.50, singleton(instance.parseAngle(new String[][] {{"4330"}}, "DMM", "en")), STRICT); + assertEquals(-3.25, singleton(instance.parseAngle(new String[][] {{"-3°15'"}}, "D°MM.m'", "en")), STRICT); } /** @@ -168,8 +187,26 @@ public final strictfp class ReferencingF */ @Test public void testFormatAngle() throws IllegalArgumentException { - assertEquals("43°30.0'", instance.formatAngle(43.50, "D°MM.m'")); - assertEquals("4330", instance.formatAngle(43.50, "DMM")); - assertEquals("-3°15.0'", instance.formatAngle(-3.25, "D°MM.m'")); + assertEquals("43°30.0'", singleton(instance.formatAngle(new double[][] {{43.50}}, "D°MM.m'", "en"))); + assertEquals("4330", singleton(instance.formatAngle(new double[][] {{43.50}}, "DMM", "en"))); + assertEquals("-3°15.0'", singleton(instance.formatAngle(new double[][] {{-3.25}}, "D°MM.m'", "en"))); + } + + /** + * Ensures that the given array contains exactly one element and returns that element. + */ + private static double singleton(final double[][] value) { + assertEquals("array length", 1, value.length); + assertEquals("array length", 1, value[0].length); + return value[0][0]; + } + + /** + * Ensures that the given array contains exactly one element and returns that element. + */ + private static String singleton(final String[][] value) { + assertEquals("array length", 1, value.length); + assertEquals("array length", 1, value[0].length); + return value[0][0]; } } Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Sat Jun 11 21:16:39 2016 @@ -20,6 +20,7 @@ import org.opengis.referencing.crs.Coord import org.opengis.referencing.crs.GeodeticCRS; import org.opengis.referencing.crs.SingleCRS; import org.opengis.util.FactoryException; +import org.opengis.util.NoSuchIdentifierException; import org.apache.sis.referencing.crs.DefaultCompoundCRS; import org.apache.sis.referencing.crs.DefaultGeographicCRS; import org.apache.sis.referencing.crs.HardCodedCRS; @@ -40,7 +41,7 @@ import static org.apache.sis.test.Assert * * @author Martin Desruisseaux (Geomatys) * @since 0.4 - * @version 0.7 + * @version 0.8 * @module */ @DependsOn({ @@ -106,6 +107,21 @@ public final strictfp class CRSTest exte } /** + * Test {@link CRS#forCode(String)} with values that should be invalid. + * + * @throws FactoryException if an error other than {@link NoSuchIdentifierException} happened. + */ + @Test + public void testForInvalidCode() throws FactoryException { + try { + CRS.forCode("EPSG:4"); + fail("Should not find EPSG:4"); + } catch (NoSuchIdentifierException e) { + assertEquals("4", e.getIdentifierCode()); + } + } + + /** * Tests simple WKT parsing. It is not the purpose of this class to test extensively the WKT parser; * those tests are rather done by {@link org.apache.sis.io.wkt.GeodeticObjectParserTest}. * Here we merely test that {@link CRS#fromWKT(String)} is connected to the parser. Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1747935&r1=1747934&r2=1747935&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java [UTF-8] Sat Jun 11 21:16:39 2016 @@ -103,10 +103,10 @@ public final class Locales extends Stati */ private static final short[] ISO3, ISO2; static { - final Short CONFLICT = 0; // Sentinal value for conflicts (paranoiac safety). + final Short CONFLICT = 0; // Sentinal value for conflicts (paranoiac safety). final Map map = new TreeMap<>(); for (final Locale locale : POOL.values()) { - short type = LANGUAGE; // 0 for language, or leftmost bit set for country. + short type = LANGUAGE; // 0 for language, or leftmost bit set for country. do { // Executed exactly twice: once for language, than once for country. final short alpha2 = toNumber((type == LANGUAGE) ? locale.getLanguage() : locale.getCountry(), type); if (alpha2 != 0) { @@ -114,7 +114,7 @@ public final class Locales extends Stati try { alpha3 = toNumber((type == LANGUAGE) ? locale.getISO3Language() : locale.getISO3Country(), type); } catch (MissingResourceException e) { - continue; // No 3-letters code to map for this locale. + continue; // No 3-letters code to map for this locale. } if (alpha3 != 0 && alpha3 != alpha2) { final Short p = map.put(alpha3, alpha2); @@ -127,7 +127,7 @@ public final class Locales extends Stati } } while ((type ^= COUNTRY) != LANGUAGE); } - while (map.values().remove(CONFLICT)); // Remove all conflicts that we may have found. + while (map.values().remove(CONFLICT)); // Remove all conflicts that we may have found. ISO3 = new short[map.size()]; ISO2 = new short[map.size()]; int i = 0; @@ -298,8 +298,8 @@ filter: for (final Locale locale : local } /** - * Converts a 3-letters ISO code to a 2-letters one. If the given code is not recognized, - * then this method returns {@code code} unmodified. + * Converts a 3-letters ISO code to a 2-letters one. + * If the given code is not recognized, then this method returns {@code code} unmodified. * * @param code The 3-letters code. * @param type Either {@link #LANGUAGE} or {@link #COUNTRY}.