Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -16,14 +16,22 @@ */ package org.apache.sis.referencing.operation.transform; +import java.util.Set; import org.opengis.util.NoSuchIdentifierException; +import org.opengis.referencing.operation.Conversion; +import org.opengis.referencing.operation.Projection; +import org.opengis.referencing.operation.SingleOperation; +import org.opengis.referencing.operation.OperationMethod; +import org.apache.sis.internal.referencing.provider.Affine; +import org.apache.sis.internal.util.Constants; +import org.apache.sis.test.DependsOnMethod; import org.apache.sis.test.DependsOn; import org.apache.sis.test.TestCase; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; +import static org.opengis.test.Assert.*; /** @@ -37,7 +45,7 @@ import static org.junit.Assert.*; * @module */ @DependsOn({ - org.apache.sis.referencing.operation.DefaultOperationMethodTest.class, + org.apache.sis.internal.referencing.provider.AllProvidersTest.class, OperationMethodSetTest.class }) public final strictfp class DefaultMathTransformFactoryTest extends TestCase { @@ -63,9 +71,25 @@ public final strictfp class DefaultMathT } /** + * Tests the {@link DefaultMathTransformFactory#getOperationMethod(String)} method. + * + * @throws NoSuchIdentifierException Should never happen. + */ + @Test + public void testGetOperationMethod() throws NoSuchIdentifierException { + // A conversion which is not a projection. + OperationMethod method = factory.getOperationMethod(Constants.AFFINE); + assertInstanceOf("Affine", Affine.class, method); + + // Same than above, using EPSG code. + assertSame("EPSG:9624", method, factory.getOperationMethod("EPSG:9624")); + } + + /** * Tests non-existent operation method. */ @Test + @DependsOnMethod("testGetOperationMethod") public void testNonExistentCode() { try { factory.getOperationMethod("EPXX:9624"); @@ -75,4 +99,29 @@ public final strictfp class DefaultMathT assertTrue(message, message.contains("EPXX:9624")); } } + + /** + * Tests the {@link DefaultMathTransformFactory#getAvailableMethods(Class)} method. + * + * @throws NoSuchIdentifierException Should never happen. + */ + @Test + @DependsOnMethod("testGetOperationMethod") + public void testGetAvailableMethods() throws NoSuchIdentifierException { + final Set<OperationMethod> transforms = factory.getAvailableMethods(SingleOperation.class); + final Set<OperationMethod> conversions = factory.getAvailableMethods(Conversion.class); + final Set<OperationMethod> projections = factory.getAvailableMethods(Projection.class); + /* + * Following tests should not cause loading of more classes than needed. + */ + assertFalse(transforms .isEmpty()); + assertFalse(conversions.isEmpty()); + assertTrue (projections.isEmpty()); + assertTrue (conversions.contains(factory.getOperationMethod(Constants.AFFINE))); + /* + * Following tests will force instantiation of all remaining OperationMethod. + */ + assertTrue("Conversions should be a subset of transforms.", transforms .containsAll(conversions)); + assertTrue("Projections should be a subset of conversions.", conversions.containsAll(projections)); + } }
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/ReferencingAssert.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -17,7 +17,6 @@ package org.apache.sis.test; import java.util.Collection; -import java.util.Set; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.awt.geom.AffineTransform; @@ -34,13 +33,14 @@ import org.opengis.referencing.cs.AxisDi import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.cs.RangeMeaning; import org.opengis.util.GenericName; -import org.apache.sis.internal.util.Constants; import org.apache.sis.geometry.AbstractEnvelope; import org.apache.sis.geometry.GeneralDirectPosition; +import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.util.iso.DefaultNameSpace; import static java.lang.StrictMath.*; +import static org.apache.sis.internal.util.Constants.EPSG; /** @@ -65,20 +65,53 @@ public strictfp class ReferencingAssert } /** - * Asserts that the string representation of the unique identifier of the given object is equals to the given + * Asserts that the given identifier has the expected code and the {@code "OGC"} code space. + * The authority is expected to be {@link Citations#OGC}. We expect the exact same authority + * instance because identifiers in OGC namespace are often hard-coded in SIS. + * + * @param expected The expected identifier code. + * @param actual The identifier to verify. + * + * @since 0.6 + */ + public static void assertOgcIdentifierEquals(final String expected, final Identifier actual) { + assertNotNull(actual); + assertSame("Authority", Citations.OGC, actual.getAuthority()); + Assert.assertIdentifierEquals(null, "OGC", "OGC", null, expected, actual); + } + + /** + * Asserts that the given identifier has the expected code and the {@code "EPSG"} code space. + * The authority is expected to have the {@code "OGP"} title or alternate title. + * + * @param expected The expected identifier code. + * @param actual The identifier to verify. + * + * @since 0.5 + */ + public static void assertEpsgIdentifierEquals(final String expected, final Identifier actual) { + assertNotNull(actual); + assertEquals("code", expected, actual.getCode()); + assertEquals("codeSpace", EPSG, actual.getCodeSpace()); + assertEquals("authority", "OGP", Citations.getIdentifier(actual.getAuthority())); + assertEquals("identifier", EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + expected, + IdentifiedObjects.toString(actual)); + } + + /** + * Asserts that the string representation of the unique identifier in the given collection is equals to the given * EPSG code. As a special case if the given code is 0, then this method verifies that the given object has no * identifier. * - * @param code The expected EPSG code, or {@code 0} if we expect no EPSG code. - * @param object The object for which to test the EPSG code. + * @param expected The expected EPSG code, or {@code 0} if we expect no EPSG code. + * @param actual The set of identifiers in which to verify the EPSG code. */ - public static void assertIdentifierEqualsEPSG(final int code, final IdentifiedObject object) { - final Set<Identifier> identifiers = object.getIdentifiers(); - if (code == 0) { - assertTrue("identifiers.isEmpty()", identifiers.isEmpty()); + public static void assertEpsgIdentifierEquals(final int expected, final Collection<? extends Identifier> actual) { + assertNotNull(actual); + if (expected == 0) { + assertTrue("identifiers.isEmpty()", actual.isEmpty()); } else { - assertEquals("identifier", Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code, - IdentifiedObjects.toString(TestUtilities.getSingleton(identifiers))); + assertEpsgIdentifierEquals(String.valueOf(expected), TestUtilities.getSingleton(actual)); } } Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -78,13 +78,17 @@ import org.junit.BeforeClass; org.apache.sis.parameter.MatrixParametersTest.class, org.apache.sis.parameter.MatrixParametersAlphaNumTest.class, org.apache.sis.parameter.TensorValuesTest.class, + org.apache.sis.parameter.MapProjectionParametersTest.class, org.apache.sis.referencing.operation.DefaultFormulaTest.class, org.apache.sis.referencing.operation.DefaultOperationMethodTest.class, + org.apache.sis.internal.referencing.provider.AffineTest.class, + org.apache.sis.internal.referencing.provider.LongitudeRotationTest.class, + org.apache.sis.internal.referencing.provider.MapProjectionTest.class, + org.apache.sis.internal.referencing.provider.AllProvidersTest.class, org.apache.sis.referencing.operation.transform.OperationMethodSetTest.class, org.apache.sis.referencing.operation.transform.DefaultMathTransformFactoryTest.class, org.apache.sis.internal.referencing.OperationMethodsTest.class, - org.apache.sis.internal.referencing.provider.AffineTest.class, org.apache.sis.referencing.datum.BursaWolfParametersTest.class, org.apache.sis.referencing.datum.TimeDependentBWPTest.class, Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -74,12 +74,20 @@ public final class Constants extends Sta /** * Name of the {@value} projection parameter, which is handled specially during WKT formatting. */ - public static final String SEMI_MAJOR = "semi_major", SEMI_MINOR = "semi_minor"; + public static final String SEMI_MAJOR = "semi_major", + SEMI_MINOR = "semi_minor"; + + /** + * The OGC parameter name for the standard parallels. + */ + public static final String STANDARD_PARALLEL_1 = "standard_parallel_1", + STANDARD_PARALLEL_2 = "standard_parallel_2"; /** * Name of the {@value} matrix parameters. */ - public static final String NUM_ROW = "num_row", NUM_COL = "num_col"; + public static final String NUM_ROW = "num_row", + NUM_COL = "num_col"; /** * The OGC name for <cite>"Affine parametric transformation"</cite>. Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -51,7 +51,7 @@ import java.util.Objects; * * @author Martin Desruisseaux (IRD) * @since 0.3 - * @version 0.5 + * @version 0.6 * @module * * @see RangeFormat @@ -109,6 +109,22 @@ public class MeasurementRange<E extends } /** + * Constructs a range of {@code double} values greater than the given value. + * The {@code minValue} is often zero for creating a range of strictly positive values. + * This method may return a shared instance, at implementation choice. + * + * @param minValue The minimal value (exclusive), or {@link Double#NEGATIVE_INFINITY} if none. + * @param unit The unit of measurement, or {@code null} if unknown. + * @return The new range of numeric values greater than the given value. + * + * @since 0.6 + */ + public static MeasurementRange<Double> createGreaterThan(final double minValue, final Unit<?> unit) { + return unique(new MeasurementRange<>(Double.class, + valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), false, null, false, unit)); + } + + /** * Constructs a range using the smallest type of {@link Number} that can hold the given values. * This method performs the same work than {@link NumberRange#createBestFit * NumberRange.createBestFit(…)} with an additional {@code unit} argument. @@ -133,7 +149,7 @@ public class MeasurementRange<E extends if (type == null) { return null; } - return (MeasurementRange) unique(new MeasurementRange(type, + return unique(new MeasurementRange(type, Numbers.cast(minValue, type), isMinIncluded, Numbers.cast(maxValue, type), isMaxIncluded, unit)); } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -71,7 +71,8 @@ package org.apache.sis.util; * <td>Parses axis names and creates transforms between {@link org.opengis.referencing.cs.CoordinateSystem} * instances.</td></tr> * <tr><td>{@link org.apache.sis.parameter.Parameters}</td> - * <td>Creates, searches or modifies {@link org.opengis.parameter.ParameterValue} instances.</td></tr> + * <td>Creates, searches or modifies {@link org.opengis.parameter.ParameterValue} instances + * in a group of parameters.</td></tr> * * <tr><th colspan="2" class="hsep">Input / Output (including CRS, XML, images)</th></tr> * <tr><td>{@link org.apache.sis.io.IO}</td> @@ -97,7 +98,7 @@ package org.apache.sis.util; * <td>Create {@link ObjectConverter} instances, or collection views using object converters.</td></tr> * </table> * - * @author Martin Desruisseaux (Geomatys) + * @author Martin Desruisseaux (Geomatys) * @since 0.3 * @version 0.3 * @module Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -29,6 +29,7 @@ import java.util.NoSuchElementException; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.LogRecord; +import java.lang.reflect.Modifier; import org.opengis.util.CodeList; import org.opengis.util.Enumerated; import org.opengis.util.InternationalString; @@ -68,7 +69,7 @@ import org.apache.sis.util.logging.Loggi * * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.3 - * @version 0.4 + * @version 0.6 * @module */ public class IndexedResourceBundle extends ResourceBundle implements Localized { @@ -404,7 +405,7 @@ public class IndexedResourceBundle exten } replacement = message; } else if (element instanceof Class<?>) { - replacement = Classes.getShortName((Class<?>) element); + replacement = Classes.getShortName(getPublicType((Class<?>) element)); } else if (element instanceof Enumerated) { replacement = Types.getCodeTitle((Enumerated) element).toString(getLocale()); } @@ -421,6 +422,23 @@ public class IndexedResourceBundle exten } /** + * If the given class is not public, returns the first public interface or the first public super-class. + * This is for avoiding confusing the user with private class in message like "Value can not be instance + * of XYZ". In the worst case (nothing public other than {@code Object}), returns {@code Object.class}. + */ + private static Class<?> getPublicType(Class<?> c) { + while (!Modifier.isPublic(c.getModifiers())) { + for (final Class<?> type : c.getInterfaces()) { + if (Modifier.isPublic(type.getModifiers())) { + return type; + } + } + c = c.getSuperclass(); + } + return c; + } + + /** * Gets a string for the given key and appends "…" to it. * This method is typically used for creating menu items. * Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] Tue Mar 17 20:37:55 2015 @@ -18,6 +18,7 @@ package org.apache.sis.test; import java.util.Set; import java.util.Map; +import java.util.Collection; import java.util.Enumeration; import java.util.LinkedHashSet; import java.util.LinkedHashMap; @@ -142,13 +143,15 @@ public strictfp class Assert extends org } /** - * Asserts that the given set contains the same elements. + * Asserts that the given set contains the same elements, ignoring order. * In case of failure, this method lists the missing or unexpected elements. * + * <p>The given collections are typically instances of {@link Set}, but this is not mandatory.</p> + * * @param expected The expected set, or {@code null}. * @param actual The actual set, or {@code null}. */ - public static void assertSetEquals(final Set<?> expected, final Set<?> actual) { + public static void assertSetEquals(final Collection<?> expected, final Collection<?> actual) { if (expected != null && actual != null && !expected.isEmpty()) { final Set<Object> r = new LinkedHashSet<>(expected); assertTrue("The two sets are disjoint.", r.removeAll(actual)); @@ -157,7 +160,9 @@ public strictfp class Assert extends org assertTrue("The two sets are disjoint.", r.removeAll(expected)); assertTrue("The set contains unexpected elements: " + r, r.isEmpty()); } - assertEquals("Set.equals(Object) failed:", expected, actual); + if (expected instanceof Set<?> && actual instanceof Set<?>) { + assertEquals("Set.equals(Object) failed:", expected, actual); + } } /** Modified: sis/branches/JDK7/ide-project/NetBeans/build.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/build.xml?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/ide-project/NetBeans/build.xml (original) +++ sis/branches/JDK7/ide-project/NetBeans/build.xml Tue Mar 17 20:37:55 2015 @@ -62,6 +62,13 @@ </fileset> </concat> + <!-- OperationMethod implementations to be loaded by ServiceLoader. --> + <concat destfile="${build.classes.dir}/META-INF/services/org.opengis.referencing.operation.OperationMethod" encoding="UTF-8" fixlastline="yes"> + <fileset dir="${project.root}"> + <include name="*/*/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod"/> + </fileset> + </concat> + <!-- ObjectConverter implementations to be loaded by ServiceLoader. --> <concat destfile="${build.classes.dir}/META-INF/services/org.apache.sis.util.ObjectConverter" encoding="UTF-8" fixlastline="yes"> <fileset dir="${project.root}"> Modified: sis/branches/JDK7/src/main/javadoc/stylesheet.css URL: http://svn.apache.org/viewvc/sis/branches/JDK7/src/main/javadoc/stylesheet.css?rev=1667396&r1=1667395&r2=1667396&view=diff ============================================================================== --- sis/branches/JDK7/src/main/javadoc/stylesheet.css (original) +++ sis/branches/JDK7/src/main/javadoc/stylesheet.css Tue Mar 17 20:37:55 2015 @@ -187,6 +187,9 @@ ul.verbose li { margin-bottom: 6px; } +span.deprecated { + text-decoration: line-through; +}
