sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1786763 [2/2] - in /sis/branches/JDK7: ./ core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ core/sis-referencing-by-identifiers/src/test/java/org/apache/sis/referencing/gazetteer/ core/sis-referencing/...
Date Mon, 13 Mar 2017 19:06:47 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -98,13 +98,12 @@ import static org.apache.sis.geometry.Ab
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see GeneralEnvelope
  * @see org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox
  */
-@SuppressWarnings("CloneableClassWithoutClone")    // No additional fields compared to parent.
 public class Envelope2D extends Rectangle2D.Double implements Envelope, Emptiable, Cloneable
{
     /**
      * Serial number for inter-operability with different versions.
@@ -284,6 +283,29 @@ public class Envelope2D extends Rectangl
     }
 
     /**
+     * Sets this envelope to the given rectangle. If the given rectangle is also an instance
of {@link Envelope}
+     * (typically as another {@code Envelope2D}) and has a non-null Coordinate Reference
System (CRS), then the
+     * CRS of this envelope will be set to the CRS of the given envelope.
+     *
+     * @param rect  the rectangle to copy coordinates from.
+     *
+     * @since 0.8
+     */
+    @Override
+    public void setRect(final Rectangle2D rect) {
+        if (rect == this) {
+            return;         // Optimization for methods chaining like env.setRect(Shapes.transform(…,
env))
+        }
+        if (rect instanceof Envelope) {
+            final CoordinateReferenceSystem envelopeCRS = ((Envelope) rect).getCoordinateReferenceSystem();
+            if (envelopeCRS != null) {
+                setCoordinateReferenceSystem(envelopeCRS);
+            }
+        }
+        super.setRect(rect);
+    }
+
+    /**
      * Returns the number of dimensions, which is always 2.
      *
      * @return always 2 for bi-dimensional objects.
@@ -444,6 +466,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMinimum(int) minimal} ordinate value for dimension 0.
+     * The default implementation invokes <code>{@linkplain #getMinimum(int) getMinimum}(0)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #x x})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the minimal ordinate value for dimension 0.
      */
@@ -454,6 +479,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMinimum(int) minimal} ordinate value for dimension 1.
+     * The default implementation invokes <code>{@linkplain #getMinimum(int) getMinimum}(1)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #y y})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the minimal ordinate value for dimension 1.
      */
@@ -464,6 +492,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMaximum(int) maximal} ordinate value for dimension 0.
+     * The default implementation invokes <code>{@linkplain #getMaximum(int) getMinimum}(0)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #x x} + {@linkplain
#width width})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the maximal ordinate value for dimension 0.
      */
@@ -474,6 +505,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMaximum(int) maximal} ordinate value for dimension 1.
+     * The default implementation invokes <code>{@linkplain #getMaximum(int) getMinimum}(1)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #y y} + {@linkplain
#height height})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the maximal ordinate value for dimension 1.
      */
@@ -484,6 +518,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMedian(int) median} ordinate value for dimension 0.
+     * The default implementation invokes <code>{@linkplain #getMedian(int) getMedian}(0)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #x x} + {@linkplain
#width width}/2)
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the median ordinate value for dimension 0.
      */
@@ -494,6 +531,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getMedian(int) median} ordinate value for dimension 1.
+     * The default implementation invokes <code>{@linkplain #getMedian(int) getMedian}(1)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #y y} + {@linkplain
#height height}/2)
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the median ordinate value for dimension 1.
      */
@@ -504,6 +544,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getSpan(int) span} for dimension 0.
+     * The default implementation invokes <code>{@linkplain #getSpan(int) getSpan}(0)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #width width})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the span for dimension 0.
      */
@@ -514,6 +557,9 @@ public class Envelope2D extends Rectangl
 
     /**
      * Returns the {@linkplain #getSpan(int) span} for dimension 1.
+     * The default implementation invokes <code>{@linkplain #getSpan(int) getSpan}(1)</code>.
+     * The result is the standard {@link Rectangle2D} value (namely {@linkplain #height height})
+     * only if the envelope is not spanning the anti-meridian.
      *
      * @return the span for dimension 1.
      */
@@ -756,7 +802,7 @@ public class Envelope2D extends Rectangl
             final Envelope2D env = (Envelope2D) rect;
             return intersects(env.x, env.y, env.width, env.height);
         }
-        return super.contains(rect);
+        return super.intersects(rect);
     }
 
     /**
@@ -885,7 +931,7 @@ public class Envelope2D extends Rectangl
      */
     @Override
     public Envelope2D createUnion(final Rectangle2D rect) {
-        final Envelope2D union = (Envelope2D) clone();
+        final Envelope2D union = clone();
         union.add(rect);
         assert union.isEmpty() || (union.contains(this) && union.contains(rect))
: union;
         return union;
@@ -1090,6 +1136,16 @@ public class Envelope2D extends Rectangl
     }
 
     /**
+     * Returns a clone of this envelope.
+     *
+     * @return a clone of this envelope.
+     */
+    @Override
+    public Envelope2D clone() {
+        return (Envelope2D) super.clone();
+    }
+
+    /**
      * Formats this envelope as a "{@code BOX}" element.
      * The output is of the form "{@code BOX(}{@linkplain #getLowerCorner()
      * lower corner}{@code ,}{@linkplain #getUpperCorner() upper corner}{@code )}".

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -391,6 +391,9 @@ public class GeneralEnvelope extends Arr
      *         the expected number of dimensions.
      */
     public void setEnvelope(final Envelope envelope) throws MismatchedDimensionException
{
+        if (envelope == this) {
+            return;     // Optimization for methods chaining like env.setEnvelope(Envelopes.transform(env,
crs))
+        }
         ensureNonNull("envelope", envelope);
         final int beginIndex = beginIndex();
         final int dimension = endIndex() - beginIndex;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -386,6 +386,7 @@ public final class Shapes2D extends Stat
      * @see #transform(MathTransform2D, Rectangle2D, Rectangle2D)
      * @see Envelopes#transform(CoordinateOperation, Envelope)
      */
+    @SuppressWarnings("null")
     public static Rectangle2D transform(final CoordinateOperation operation,
                                         final Rectangle2D         envelope,
                                               Rectangle2D         destination)

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -132,7 +132,7 @@ public abstract class GeocentricAffine e
         RX = createRotation(builder.addIdentifier("8608"), "X-axis rotation", "ex");
         RY = createRotation(builder.addIdentifier("8609"), "Y-axis rotation", "ey");
         RZ = createRotation(builder.addIdentifier("8610"), "Z-axis rotation", "ez");
-        DS = builder.addIdentifier("8611").addName("Scale difference").addName(Citations.OGC,
"ppm").create(1, Units.PPM);
+        DS = builder.addIdentifier("8611").addName("Scale difference").addName(Citations.OGC,
"ppm").create(0, Units.PPM);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -111,8 +111,10 @@ public final class PolarStereographicA e
 
     /**
      * False Easting and false Northing value used in Universal Polar Stereographic (UPS)
projections.
+     * Represented as an integer for the convenience of Military Reference Grid System (MGRS)
or other
+     * grid systems.
      */
-    public static final double UPS_SHIFT = 2000000;
+    public static final int UPS_SHIFT = 2000000;
 
     /**
      * Sets the parameter values for a Universal Polar Stereographic projection

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -180,6 +180,14 @@ public final class TransverseMercator ex
                 }
                 return false;
             }
+
+            /** Indicates whether the given geographic area intersects the regions that need
to be handled in a special way. */
+            @Override public boolean isSpecialCase(final double φmin, final double φmax,
final double λmin, final double λmax) {
+                if (φmax >= NORWAY_BOUNDS && φmin < NORTH_BOUNDS) {
+                    return super.zone(0, λmax) >= 31 && super.zone(0, λmin)
<= 37;
+                }
+                return false;
+            }
         },
 
         /**
@@ -372,6 +380,19 @@ public final class TransverseMercator ex
         }
 
         /**
+         * Indicates whether the given geographic area intersects the regions that need to
be handled in a special way.
+         *
+         * @param  φmin  southernmost latitude in degrees.
+         * @param  φmax  northernmost latitude in degrees.
+         * @param  λmin  westernmost longitude in degrees.
+         * @param  λmax  easternmost longitude in degrees.
+         * @return whether the given area intersects a region that needs to be handled as
a special case.
+         */
+        public boolean isSpecialCase(final double φmin, final double φmax, final double
λmin, final double λmax) {
+            return false;
+        }
+
+        /**
          * First exception in UTM projection, corresponding to latitude band V.
          * This method is public for {@code MilitaryGridReferenceSystemTest.verifyZonerConsistency()}
purpose only.
          *
@@ -379,7 +400,7 @@ public final class TransverseMercator ex
          * @return whether the given latitude is in the Norway latitude band.
          */
         public static boolean isNorway(final double φ) {
-            return (φ >= 56) && (φ < 64);
+            return (φ >= NORWAY_BOUNDS) && (φ < 64);
         }
 
         /**
@@ -401,6 +422,12 @@ public final class TransverseMercator ex
         public static final double SOUTH_BOUNDS = -80;
 
         /**
+         * Southernmost bounds (inclusive) of the latitude band that contains Norway ({@code
'V'}).
+         * This is the first latitude band where we may need to handle special cases (Norway
and Svalbard).
+         */
+        private static final double NORWAY_BOUNDS = 56;
+
+        /**
          * Southernmost bounds (inclusive) of the last latitude band, which contains Svalbard.
          * This latitude band is 12° height instead of 8°.
          */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterator.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterator.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterator.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -24,6 +24,11 @@ package org.apache.sis.internal.jdk8;
  */
 public abstract interface Spliterator<T> {
     /**
+     * Flag for iterators that return only distinct values.
+     */
+    public static final int DISTINCT = 0x1;
+
+    /**
      * Flag for iterators that return the values in some specified order.
      */
     public static final int ORDERED = 0x10;

Added: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java?rev=1786763&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java
(added)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jdk8;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Placeholder for the {@link java.util.Spliterators} class.
+ */
+public final class Spliterators {
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private Spliterators() {
+    }
+
+    /**
+     * Wraps the given spliterator in an iterator.
+     *
+     * @param  <T>  type of elements returned by the iterator.
+     * @param  spliterator  the spliterator to wrap.
+     * @return the iterator for the given spliterator.
+     */
+    public static <T> Iterator<T> iterator(final Spliterator<? extends T>
spliterator) {
+        final class Iter implements Iterator<T>, Consumer<T> {
+            private boolean hasNext;
+            private T next;
+
+            @Override
+            public void accept(T element) {
+                next = element;
+            }
+
+            @Override
+            public boolean hasNext() {
+                if (!hasNext) {
+                    hasNext = spliterator.tryAdvance(this);
+                }
+                return hasNext;
+            }
+
+            @Override
+            public T next() {
+                if (hasNext()) {
+                    hasNext = false;
+                    return next;
+                }
+                throw new NoSuchElementException();
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        }
+        return new Iter();
+    }
+}

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/Spliterators.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1786763&r1=1786762&r2=1786763&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
[UTF-8] Mon Mar 13 19:06:47 2017
@@ -302,7 +302,7 @@ public class AngleFormat extends Format
     /**
      * The rounding mode, or {@code null} for the default mode (which is {@link RoundingMode#HALF_EVEN}).
      *
-     * @see #RoundingMode()
+     * @see #getRoundingMode()
      */
     private RoundingMode roundingMode;
 



Mime
View raw message