This is an automated email from the ASF dual-hosted git repository.
jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new d324b2e6bc feat(Geometry): implement Java array factory builder,
factorize array code, prepare FFM array factory classes
d324b2e6bc is described below
commit d324b2e6bc4dcf9f3974e2100aab9bb4cb4c9ffb
Author: jsorel <[email protected]>
AuthorDate: Wed Feb 25 11:48:24 2026 +0100
feat(Geometry): implement Java array factory builder, factorize array code,
prepare FFM array factory classes
---
.../apache/sis/geometries/math/AbstractArray.java | 19 +-
.../main/org/apache/sis/geometries/math/Array.java | 11 +
.../apache/sis/geometries/math/ArrayFactory.java | 179 +++++++-
.../sis/geometries/math/ArrayFactoryFFM.java | 493 +++++++++++++++++++++
.../{JavaFactory.java => ArrayFactoryJava.java} | 437 ++++--------------
.../org/apache/sis/geometries/math/NDArray.java | 7 +
.../org/apache/sis/geometries/math/NDArrays.java | 56 +--
.../apache/sis/geometries/math/ArrayNbTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNdTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNfTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNiTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNlTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNsTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNubTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNuiTest.java | 2 +-
.../apache/sis/geometries/math/ArrayNusTest.java | 2 +-
16 files changed, 821 insertions(+), 399 deletions(-)
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractArray.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractArray.java
index 723b24bdae..a9b0bf0398 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractArray.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/AbstractArray.java
@@ -16,6 +16,8 @@
*/
package org.apache.sis.geometries.math;
+import java.util.Arrays;
+
/**
*
@@ -25,7 +27,11 @@ public abstract class AbstractArray implements Array {
@Override
public Array resize(long newSize) {
- final Array copy = NDArrays.of(getSampleSystem(), getDataType(),
newSize);
+ final Array copy = getFactory().builder()
+ .dataType(getDataType())
+ .system(getSampleSystem())
+ .shape(newSize)
+ .build();
final Cursor cursor = cursor();
while (cursor.next()) {
final long idx = cursor.coordinate();
@@ -76,4 +82,15 @@ public abstract class AbstractArray implements Array {
public int hashCode() {
return getDataType().hashCode() | (getDimension() * 21) |
((int)getLength() * 7);
}
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Array(");
+ sb.append(getDataType().name()).append(',');
+ sb.append("shape:").append(Arrays.toString(getShape())).append(',');
+
sb.append("systemSize:").append(getSampleSystem().getSize()).append(',');
+ sb.append(getFactory().getClass().getSimpleName()).append(')');
+ return sb.toString();
+ }
}
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Array.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Array.java
index 35735d8226..3e725ec1d3 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Array.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/Array.java
@@ -85,6 +85,17 @@ public interface Array extends NDArray {
*/
void get(long index, Tuple buffer);
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ default void set(Tuple buffer) {
+ Cursor cursor = cursor();
+ while (cursor.next()) {
+ cursor.samples().set(buffer);
+ }
+ }
+
/**
* Set tuple.
*
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactory.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactory.java
index 59abc4f4e3..12730cc194 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactory.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactory.java
@@ -17,6 +17,8 @@
package org.apache.sis.geometries.math;
import java.lang.foreign.SegmentAllocator;
+import java.util.Collection;
+import java.util.Iterator;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
/**
@@ -26,13 +28,12 @@ import
org.opengis.referencing.crs.CoordinateReferenceSystem;
*/
public interface ArrayFactory {
- public static final ArrayFactory JAVA = JavaFactory.INSTANCE;
+ public static final ArrayFactory JAVA = ArrayFactoryJava.INSTANCE;
public static ArrayFactory newFFMFactory(SegmentAllocator allocator) {
- throw new UnsupportedOperationException();
+ return new ArrayFactoryFFM(allocator);
}
-
Builder builder();
public static interface Builder {
@@ -74,16 +75,18 @@ public interface ArrayFactory {
/**
* Set the initial array values to the given values.
*
- * @param values, can be any java array type, or a Iterable<Tuple> or
a ByteBuffer
- * @return
+ * @param values, can be any java primitive array, a Collection<Tuple
or primitive array> or another Array
+ * @param canUse, if true the factory is allowed to use the given
values instances directly if it is possible.
+ * if false, values will always be copied
+ * @return this builder
*/
- Builder values(Object values);
+ Builder values(Object values, boolean canUse);
/**
* Set the initial array values to the given value.
* Value will be duplicated to fill the array.
*
- * @param values, can be any java array type, or a Iterable<Tuple> or
a ByteBuffer
+ * @param values, can be any java primitive array, a Tuple
* @return this builder
*/
Builder fill(Object values);
@@ -110,4 +113,166 @@ public interface ArrayFactory {
}
+
+ public static abstract class AbstractBuilder<T extends Builder> implements
Builder {
+
+ protected long[] shape;
+ protected SampleSystem system;
+ protected DataType dataType;
+ protected Object values;
+ protected boolean canUseValues;
+ protected Object fill;
+
+ @Override
+ public T shape(long... shape) {
+ this.shape = shape;
+ return (T)this;
+ }
+
+ @Override
+ public T system(SampleSystem system) {
+ this.system = system;
+ return (T)this;
+ }
+
+ @Override
+ public T dataType(DataType dataType) {
+ this.dataType = dataType;
+ return (T)this;
+ }
+
+ @Override
+ public T values(Object values, boolean canUse) {
+ this.values = values;
+ this.canUseValues = canUse;
+ return (T)this;
+ }
+
+ @Override
+ public T fill(Object values) {
+ this.fill = values;
+ return (T)this;
+ }
+
+ protected SampleSystem getSystem() {
+ if (system != null) {
+ return system;
+ } else if (values instanceof NDArray nd) {
+ return nd.getSampleSystem();
+ } else if (values instanceof Collection<?> col) {
+ final Iterator<?> ite = col.iterator();
+ if (ite.hasNext()) {
+ final Object o = ite.next();
+ if (o instanceof Tuple<?> t) {
+ return t.getSampleSystem();
+ } else if (o != null && o.getClass().isArray()) {
+ final int size = java.lang.reflect.Array.getLength(o);
+ return SampleSystem.ofSize(size);
+ } else {
+ throw new IllegalArgumentException("Values iterable is
not made of Tuple or primitive array");
+ }
+ }
+ }
+ return SampleSystem.ofSize(1);
+ }
+
+ protected long[] getShape() {
+ final SampleSystem system = getSystem();
+ final int nbSample = system.getSize();
+
+ if (shape != null) {
+ return shape;
+ } else if (values instanceof NDArray nd) {
+ return nd.getShape();
+ } else if (values != null && values.getClass().isArray()) {
+ final int size = java.lang.reflect.Array.getLength(values);
+ if ((size % nbSample) != 0) throw new
IllegalArgumentException("Values size : " + size + "is not a multiple of sample
system size : " + nbSample);
+ return new long[]{size / nbSample};
+ } else if (values instanceof Collection<?> col) {
+ return new long[]{col.size()};
+ }
+ throw new IllegalArgumentException("Array shape could not be
inferred from parameters");
+ }
+
+ protected DataType getDataType() {
+ if (dataType != null) {
+ return dataType;
+ } else if (values instanceof NDArray nd) {
+ return nd.getDataType();
+ } else if (values != null && values.getClass().isArray()) {
+ final Class<?> componentType =
values.getClass().getComponentType();
+ return DataType.forPrimitiveType(componentType, false);
+ } else if (values instanceof Collection<?> col) {
+ final Iterator<?> ite = col.iterator();
+ if (ite.hasNext()) {
+ final Object o = ite.next();
+ if (o instanceof Tuple<?> t) {
+ return t.getDataType();
+ } else if (o != null && o.getClass().isArray()) {
+ final Class<?> componentType =
values.getClass().getComponentType();
+ return DataType.forPrimitiveType(componentType, false);
+ } else {
+ throw new IllegalArgumentException("Values iterable is
not made of Tuple or primitive array");
+ }
+ }
+ }
+ throw new IllegalArgumentException("Array data type could not be
inferred from parameters");
+ }
+
+ protected void copyOrFillValues(Array target) {
+ final int nbDim = target.getSampleSystem().getSize();
+
+ if (values != null) {
+ if (values instanceof Array array) {
+ target.set(0, array, 0, array.getLength());
+ } else if (values != null && values.getClass().isArray()) {
+ int idx = 0;
+ final Cursor cursor = target.cursor();
+ while (cursor.next()) {
+ final Tuple tuple = cursor.samples();
+ for (int i = 0; i < nbDim; i++) {
+ tuple.set(i,
java.lang.reflect.Array.getDouble(values, idx));
+ idx++;
+ }
+ }
+ } else if (values instanceof Collection<?> col) {
+ final Iterator<?> ite = col.iterator();
+ final Cursor cursor = target.cursor();
+ while (ite.hasNext()) {
+ cursor.next();
+ final Object o = ite.next();
+ final Tuple tuple = cursor.samples();
+ if (o instanceof Tuple<?> t) {
+ tuple.set(t);
+ } else if (o != null && o.getClass().isArray()) {
+ for (int i = 0; i < nbDim; i++) {
+ tuple.set(i,
java.lang.reflect.Array.getDouble(o, i));
+ }
+ } else {
+ throw new IllegalArgumentException("Values
iterable is not made of Tuple or primitive array");
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Values type not
supported");
+ }
+ } else if (fill != null) {
+
+ Tuple f;
+ if (fill instanceof Tuple t) {
+ f = t;
+ } else if (fill.getClass().isArray()) {
+ f = Vectors.create(system, target.getDataType());
+ for (int i = 0; i < nbDim; i++) {
+ f.set(i, java.lang.reflect.Array.getDouble(fill, i));
+ }
+ } else {
+ throw new IllegalArgumentException("Fill value is not a Tuple
or primitive array");
+ }
+
+ target.set(f);
+ }
+
+ }
+
+ }
}
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryFFM.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryFFM.java
new file mode 100644
index 0000000000..3a0f6fa540
--- /dev/null
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryFFM.java
@@ -0,0 +1,493 @@
+/*
+ * 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.geometries.math;
+
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.SegmentAllocator;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.List;
+import static org.apache.sis.geometries.math.DataType.BYTE;
+import static org.apache.sis.geometries.math.DataType.DOUBLE;
+import static org.apache.sis.geometries.math.DataType.FLOAT;
+import static org.apache.sis.geometries.math.DataType.INT;
+import static org.apache.sis.geometries.math.DataType.LONG;
+import static org.apache.sis.geometries.math.DataType.SHORT;
+import static org.apache.sis.geometries.math.DataType.UBYTE;
+import static org.apache.sis.geometries.math.DataType.UINT;
+import static org.apache.sis.geometries.math.DataType.USHORT;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.util.ArgumentChecks;
+
+
+/**
+ *
+ * @author Johann Sorel (Geomatys)
+ */
+public final class ArrayFactoryFFM implements ArrayFactory {
+
+ private final SegmentAllocator allocator;
+
+ ArrayFactoryFFM(SegmentAllocator allocator) {
+ this.allocator = allocator;
+ }
+
+ @Override
+ public Builder builder() {
+ return new FFMBuilder();
+ }
+
+ private final class FFMBuilder extends AbstractBuilder<FFMBuilder> {
+
+ @Override
+ public NDArray buildND() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array build() {
+ final long[] shape = getShape();
+ if (shape.length != 1) throw new IllegalArgumentException("Array
shape has more then one dimension");
+ final long nbTuple = shape[0];
+
+ final SampleSystem system = getSystem();
+ final DataType dataType = getDataType();
+ final int nbSample = system.getSize();
+
+ final long arraySize = nbTuple * nbSample;
+ final long arraySizeBytes = arraySize * (dataType.size() / 8);
+
+ final MemorySegment pointer = allocator.allocate(arraySizeBytes);
+
+ final Array array;
+ switch (dataType) {
+ case BYTE : array = new ArrayFactoryFFM.Byte(system, pointer);
break;
+ case UBYTE : array = new ArrayFactoryFFM.UByte(system,
pointer); break;
+ case SHORT : array = new ArrayFactoryFFM.Short(system,
pointer); break;
+ case USHORT : array = new ArrayFactoryFFM.UShort(system,
pointer); break;
+ case INT : array = new ArrayFactoryFFM.Int(system, pointer);
break;
+ case UINT : array = new ArrayFactoryFFM.UInt(system, pointer);
break;
+ case LONG : array = new ArrayFactoryFFM.Long(system, pointer);
break;
+ case FLOAT : array = new ArrayFactoryFFM.Float(system,
pointer); break;
+ case DOUBLE : array = new ArrayFactoryFFM.Double(system,
pointer); break;
+ default : throw new IllegalArgumentException("Unexpected data
type " + dataType);
+ }
+
+ //todo, check if we can reuse the values array
+ copyOrFillValues(array);
+ return array;
+ }
+
+ }
+
+ private abstract class FFMArray extends AbstractArray {
+
+ protected final MemorySegment array;
+ protected SampleSystem type;
+ protected final int dimension;
+ private final long length;
+
+ public FFMArray(SampleSystem type, MemorySegment pointer) {
+ this.array = pointer;
+ this.type = type;
+ this.dimension = type.getSize();
+
+ final int tupleSizeBytes = (getDataType().size() / 8) * dimension;
+ this.length = pointer.byteSize() / tupleSizeBytes;
+
+ if (array.byteSize() % tupleSizeBytes != 0) {
+ throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.byteSize());
+ }
+ }
+
+ @Override
+ public final ArrayFactory getFactory() {
+ return ArrayFactoryFFM.this;
+ }
+
+ @Override
+ public final SampleSystem getSampleSystem() {
+ return type;
+ }
+
+ @Override
+ public final void setSampleSystem(SampleSystem type) {
+ if (dimension != type.getSize()) {
+ throw new IllegalArgumentException("Target type has a
different number of dimensions");
+ }
+ this.type = type;
+ }
+
+ @Override
+ public final CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return type.getCoordinateReferenceSystem();
+ }
+
+ @Override
+ public final int getDimension() {
+ return dimension;
+ }
+
+ @Override
+ public final long getLength() {
+ return length;
+ }
+ }
+
+ private final class Byte extends FFMArray {
+
+ private Byte(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.BYTE;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class UByte extends FFMArray {
+
+ UByte(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.UBYTE;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class Short extends FFMArray {
+
+ Short(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.SHORT;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class UShort extends FFMArray {
+
+ UShort(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.USHORT;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class Int extends FFMArray {
+
+ Int(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.INT;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class UInt extends FFMArray {
+
+ UInt(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.UINT;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class Long extends FFMArray {
+
+ Long(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.LONG;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class Float extends FFMArray {
+
+ Float(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.FLOAT;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+ private final class Double extends FFMArray {
+
+ Double(SampleSystem type, MemorySegment array) {
+ super(type, array);
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.DOUBLE;
+ }
+
+ @Override
+ public void get(long index, Tuple buffer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long index, Tuple tuple) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor cursor() {
+ return new AbstractCursor(this) {
+ @Override
+ public double get(long tupleIndex, int sampleIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void set(long tupleIndex, int sampleIndex, double
value) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ }
+
+}
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/JavaFactory.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryJava.java
similarity index 81%
rename from
incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/JavaFactory.java
rename to
incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryJava.java
index c272434aca..524ee410e4 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/JavaFactory.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/ArrayFactoryJava.java
@@ -18,6 +18,15 @@ package org.apache.sis.geometries.math;
import java.util.Arrays;
import java.util.List;
+import static org.apache.sis.geometries.math.DataType.BYTE;
+import static org.apache.sis.geometries.math.DataType.DOUBLE;
+import static org.apache.sis.geometries.math.DataType.FLOAT;
+import static org.apache.sis.geometries.math.DataType.INT;
+import static org.apache.sis.geometries.math.DataType.LONG;
+import static org.apache.sis.geometries.math.DataType.SHORT;
+import static org.apache.sis.geometries.math.DataType.UBYTE;
+import static org.apache.sis.geometries.math.DataType.UINT;
+import static org.apache.sis.geometries.math.DataType.USHORT;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.util.ArgumentChecks;
@@ -26,11 +35,11 @@ import org.apache.sis.util.ArgumentChecks;
*
* @author Johann Sorel (Geomatys)
*/
-public final class JavaFactory implements ArrayFactory {
+public final class ArrayFactoryJava implements ArrayFactory {
- public static final JavaFactory INSTANCE = new JavaFactory();
+ public static final ArrayFactoryJava INSTANCE = new ArrayFactoryJava();
- private JavaFactory() {
+ private ArrayFactoryJava() {
}
@Override
@@ -38,73 +47,70 @@ public final class JavaFactory implements ArrayFactory {
return new JavaBuilder();
}
- private static final class JavaBuilder implements Builder {
+ private static final class JavaBuilder extends
AbstractBuilder<JavaBuilder> {
@Override
- public Builder shape(long... shape) {
+ public NDArray buildND() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Builder system(SampleSystem system) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
+ public Array build() {
+ final long[] shape = getShape();
+ if (shape.length != 1) throw new IllegalArgumentException("Array
shape has more then one dimension");
+ final long nbTuple = shape[0];
- @Override
- public Builder dataType(DataType type) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
+ final SampleSystem system = getSystem();
+ final DataType dataType = getDataType();
+ final int nbSample = system.getSize();
- @Override
- public Builder values(Object values) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Builder fill(Object values) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
+ final long arraySize = nbTuple * nbSample;
+ if (arraySize > Integer.MAX_VALUE) throw new
IllegalArgumentException("Array shape exceed " + Integer.MAX_VALUE + ". Use FFM
factory for very large arrays");
+ final int arraySizeI = (int) arraySize;
- @Override
- public NDArray buildND() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
+ final Array array;
+ switch (dataType) {
+ case BYTE : array = new ArrayFactoryJava.Byte(system, new
byte[arraySizeI]); break;
+ case UBYTE : array = new ArrayFactoryJava.UByte(system, new
byte[arraySizeI]); break;
+ case SHORT : array = new ArrayFactoryJava.Short(system, new
short[arraySizeI]); break;
+ case USHORT : array = new ArrayFactoryJava.UShort(system, new
short[arraySizeI]); break;
+ case INT : array = new ArrayFactoryJava.Int(system, new
int[arraySizeI]); break;
+ case UINT : array = new ArrayFactoryJava.UInt(system, new
int[arraySizeI]); break;
+ case LONG : array = new ArrayFactoryJava.Long(system, new
long[arraySizeI]); break;
+ case FLOAT : array = new ArrayFactoryJava.Float(system, new
float[arraySizeI]); break;
+ case DOUBLE : array = new ArrayFactoryJava.Double(system, new
double[arraySizeI]); break;
+ default : throw new IllegalArgumentException("Unexpected data
type " + dataType);
+ }
- @Override
- public Array build() {
- throw new UnsupportedOperationException("Not supported yet.");
+ //todo, check if we can reuse the values array
+ copyOrFillValues(array);
+ return array;
}
}
+ private static abstract class JavaArray extends AbstractArray {
- static final class Byte extends AbstractArray {
-
- private SampleSystem type;
- private final int dimension;
- private final byte[] array;
+ protected SampleSystem type;
+ protected final int dimension;
- Byte(SampleSystem type, byte[] array) {
+ public JavaArray(SampleSystem type) {
this.type = type;
this.dimension = type.getSize();
- this.array = array;
- if (array.length % dimension != 0) {
- throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
- }
}
@Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
+ public final ArrayFactory getFactory() {
+ return ArrayFactoryJava.INSTANCE;
}
@Override
- public SampleSystem getSampleSystem() {
+ public final SampleSystem getSampleSystem() {
return type;
}
@Override
- public void setSampleSystem(SampleSystem type) {
+ public final void setSampleSystem(SampleSystem type) {
if (dimension != type.getSize()) {
throw new IllegalArgumentException("Target crs has a different
number of dimensions");
}
@@ -112,19 +118,31 @@ public final class JavaFactory implements ArrayFactory {
}
@Override
- public long getLength() {
- return array.length / dimension;
+ public final CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return type.getCoordinateReferenceSystem();
}
@Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
+ public final int getDimension() {
+ return dimension;
}
+ }
+ static final class Byte extends JavaArray {
+
+ private final byte[] array;
+
+ Byte(SampleSystem type, byte[] array) {
+ super(type);
+ this.array = array;
+ if (array.length % dimension != 0) {
+ throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
+ }
+ }
@Override
- public int getDimension() {
- return dimension;
+ public long getLength() {
+ return array.length / dimension;
}
@Override
@@ -250,61 +268,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNb{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
}
- static final class UByte extends AbstractArray {
+ static final class UByte extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final byte[] array;
UByte(SampleSystem type, byte[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.UBYTE;
@@ -429,61 +411,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNub{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
}
- static final class Short extends AbstractArray {
+ static final class Short extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final short[] array;
Short(SampleSystem type, short[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.SHORT;
@@ -617,61 +563,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNs{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
}
- static final class UShort extends AbstractArray {
+ static final class UShort extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final short[] array;
UShort(SampleSystem type, short[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.USHORT;
@@ -797,61 +707,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNus{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
-
}
- static final class Int extends AbstractArray {
+ static final class Int extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final int[] array;
Int(SampleSystem type, int[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.INT;
@@ -976,21 +850,14 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNi{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
}
- static final class UInt extends AbstractArray {
+ static final class UInt extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final int[] array;
UInt(SampleSystem type, int[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
@@ -998,47 +865,18 @@ public final class JavaFactory implements ArrayFactory {
}
UInt(SampleSystem type, List<Integer> array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array.stream().mapToInt(Integer::intValue).toArray();
if (array.size() % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.size());
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.UINT;
@@ -1164,60 +1002,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNui{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
}
- static final class Long extends AbstractArray {
+ static final class Long extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final long[] array;
Long(SampleSystem type, long[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.LONG;
@@ -1331,60 +1134,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNl{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
}
- static final class Float extends AbstractArray {
+ static final class Float extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final float[] array;
Float(SampleSystem type, float[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.FLOAT;
@@ -1515,60 +1283,25 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNf{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
}
- static final class Double extends AbstractArray {
+ static final class Double extends JavaArray {
- private SampleSystem type;
- private final int dimension;
private final double[] array;
Double(SampleSystem type, double[] array) {
- this.type = type;
- this.dimension = type.getSize();
+ super(type);
this.array = array;
if (array.length % dimension != 0) {
throw new IllegalArgumentException("Array size is not
compatible, expected n*" + dimension + " but size is " + array.length);
}
}
- @Override
- public ArrayFactory getFactory() {
- return JavaFactory.INSTANCE;
- }
-
- @Override
- public SampleSystem getSampleSystem() {
- return type;
- }
-
@Override
public long getLength() {
return array.length / dimension;
}
- @Override
- public CoordinateReferenceSystem getCoordinateReferenceSystem() {
- return type.getCoordinateReferenceSystem();
- }
-
- @Override
- public void setSampleSystem(SampleSystem type) {
- if (dimension != type.getSize()) {
- throw new IllegalArgumentException("Target crs has a different
number of dimensions");
- }
- this.type = type;
- }
-
- @Override
- public int getDimension() {
- return dimension;
- }
-
@Override
public DataType getDataType() {
return DataType.DOUBLE;
@@ -1699,10 +1432,6 @@ public final class JavaFactory implements ArrayFactory {
};
}
- @Override
- public String toString() {
- return "TupleArrayNd{" + "dimension=" + dimension + ",
tuple.length=" + getLength() + ", array.length=" + array.length + '}';
- }
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArray.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArray.java
index e66568c951..f666f2b41d 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArray.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArray.java
@@ -115,6 +115,13 @@ public interface NDArray {
*/
void get(long[] index, Tuple buffer);
+ /**
+ * Fill array with given tuple value.
+ *
+ * @param buffer fill value
+ */
+ void set(Tuple buffer);
+
/**
* Set tuple.
*
diff --git
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArrays.java
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArrays.java
index 0098795e70..816b85bcc8 100644
---
a/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArrays.java
+++
b/incubator/src/org.apache.sis.geometry/main/org/apache/sis/geometries/math/NDArrays.java
@@ -47,15 +47,15 @@ public final class NDArrays {
final int dimension = type.getSize();
final Array array;
switch (dataType) {
- case BYTE : array = new JavaFactory.Byte(type, new
byte[vectors.size() * dimension]); break;
- case UBYTE : array = new JavaFactory.UByte(type, new
byte[vectors.size() * dimension]); break;
- case SHORT : array = new JavaFactory.Short(type, new
short[vectors.size() * dimension]); break;
- case USHORT : array = new JavaFactory.UShort(type, new
short[vectors.size() * dimension]); break;
- case INT : array = new JavaFactory.Int(type, new
int[vectors.size() * dimension]); break;
- case UINT : array = new JavaFactory.UInt(type, new
int[vectors.size() * dimension]); break;
- case LONG : array = new JavaFactory.Long(type, new
long[vectors.size() * dimension]); break;
- case FLOAT : array = new JavaFactory.Float(type, new
float[vectors.size() * dimension]); break;
- case DOUBLE : array = new JavaFactory.Double(type, new
double[vectors.size() * dimension]); break;
+ case BYTE : array = new ArrayFactoryJava.Byte(type, new
byte[vectors.size() * dimension]); break;
+ case UBYTE : array = new ArrayFactoryJava.UByte(type, new
byte[vectors.size() * dimension]); break;
+ case SHORT : array = new ArrayFactoryJava.Short(type, new
short[vectors.size() * dimension]); break;
+ case USHORT : array = new ArrayFactoryJava.UShort(type, new
short[vectors.size() * dimension]); break;
+ case INT : array = new ArrayFactoryJava.Int(type, new
int[vectors.size() * dimension]); break;
+ case UINT : array = new ArrayFactoryJava.UInt(type, new
int[vectors.size() * dimension]); break;
+ case LONG : array = new ArrayFactoryJava.Long(type, new
long[vectors.size() * dimension]); break;
+ case FLOAT : array = new ArrayFactoryJava.Float(type, new
float[vectors.size() * dimension]); break;
+ case DOUBLE : array = new ArrayFactoryJava.Double(type, new
double[vectors.size() * dimension]); break;
default : throw new IllegalArgumentException("Unexpected data type
" + dataType);
}
@@ -72,15 +72,15 @@ public final class NDArrays {
final int isize = Math.toIntExact(size);
final Array array;
switch (dataType) {
- case BYTE : array = new JavaFactory.Byte(type, new byte[isize]);
break;
- case UBYTE : array = new JavaFactory.UByte(type, new byte[isize]);
break;
- case SHORT : array = new JavaFactory.Short(type, new
short[isize]); break;
- case USHORT : array = new JavaFactory.UShort(type, new
short[isize]); break;
- case INT : array = new JavaFactory.Int(type, new int[isize]);
break;
- case UINT : array = new JavaFactory.UInt(type, new int[isize]);
break;
- case LONG : array = new JavaFactory.Long(type, new long[isize]);
break;
- case FLOAT : array = new JavaFactory.Float(type, new
float[isize]); break;
- case DOUBLE : array = new JavaFactory.Double(type, new
double[isize]); break;
+ case BYTE : array = new ArrayFactoryJava.Byte(type, new
byte[isize]); break;
+ case UBYTE : array = new ArrayFactoryJava.UByte(type, new
byte[isize]); break;
+ case SHORT : array = new ArrayFactoryJava.Short(type, new
short[isize]); break;
+ case USHORT : array = new ArrayFactoryJava.UShort(type, new
short[isize]); break;
+ case INT : array = new ArrayFactoryJava.Int(type, new int[isize]);
break;
+ case UINT : array = new ArrayFactoryJava.UInt(type, new
int[isize]); break;
+ case LONG : array = new ArrayFactoryJava.Long(type, new
long[isize]); break;
+ case FLOAT : array = new ArrayFactoryJava.Float(type, new
float[isize]); break;
+ case DOUBLE : array = new ArrayFactoryJava.Double(type, new
double[isize]); break;
default : throw new IllegalArgumentException("Unexpected data type
" + dataType);
}
return array;
@@ -131,7 +131,7 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, byte ... values) {
- return new JavaFactory.Byte(type, values);
+ return new ArrayFactoryJava.Byte(type, values);
}
public static Array of(CoordinateReferenceSystem crs, int ... values) {
@@ -139,7 +139,7 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, int ... values) {
- return new JavaFactory.Int(type, values);
+ return new ArrayFactoryJava.Int(type, values);
}
public static Array of(CoordinateReferenceSystem crs, short ... values) {
@@ -147,7 +147,7 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, short ... values) {
- return new JavaFactory.Short(type, values);
+ return new ArrayFactoryJava.Short(type, values);
}
public static Array of(CoordinateReferenceSystem crs, long ... values) {
@@ -155,7 +155,7 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, long ... values) {
- return new JavaFactory.Long(type, values);
+ return new ArrayFactoryJava.Long(type, values);
}
public static Array of(CoordinateReferenceSystem crs, float ... values) {
@@ -163,7 +163,7 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, float ... values) {
- return new JavaFactory.Float(type, values);
+ return new ArrayFactoryJava.Float(type, values);
}
public static Array of(CoordinateReferenceSystem crs, double ... values) {
@@ -171,23 +171,23 @@ public final class NDArrays {
}
public static Array of(SampleSystem type, double ... values) {
- return new JavaFactory.Double(type, values);
+ return new ArrayFactoryJava.Double(type, values);
}
public static Array ofUnsigned(SampleSystem type, byte ... values) {
- return new JavaFactory.UByte(type, values);
+ return new ArrayFactoryJava.UByte(type, values);
}
public static Array ofUnsigned(SampleSystem type, short ... values) {
- return new JavaFactory.UShort(type, values);
+ return new ArrayFactoryJava.UShort(type, values);
}
public static Array ofUnsigned(SampleSystem type, int ... values) {
- return new JavaFactory.UInt(type, values);
+ return new ArrayFactoryJava.UInt(type, values);
}
public static Array ofUnsigned(SampleSystem type, List<Integer> values) {
- return new JavaFactory.UInt(type, values);
+ return new ArrayFactoryJava.UInt(type, values);
}
/**
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNbTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNbTest.java
index 6bda898aae..19f683b67e 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNbTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNbTest.java
@@ -30,7 +30,7 @@ public class ArrayNbTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Byte(SampleSystem.ofSize(dim), new
byte[length*dim]);
+ return new ArrayFactoryJava.Byte(SampleSystem.ofSize(dim), new
byte[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNdTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNdTest.java
index b9e0b15f73..5f55532899 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNdTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNdTest.java
@@ -30,7 +30,7 @@ public class ArrayNdTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Double(SampleSystem.ofSize(dim), new
double[length*dim]);
+ return new ArrayFactoryJava.Double(SampleSystem.ofSize(dim), new
double[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNfTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNfTest.java
index ec2a786779..01d2f4e3d9 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNfTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNfTest.java
@@ -30,7 +30,7 @@ public class ArrayNfTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Float(SampleSystem.ofSize(dim), new
float[length*dim]);
+ return new ArrayFactoryJava.Float(SampleSystem.ofSize(dim), new
float[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNiTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNiTest.java
index c18a32e5ea..8d6fb8c418 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNiTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNiTest.java
@@ -30,7 +30,7 @@ public class ArrayNiTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Int(SampleSystem.ofSize(dim), new
int[length*dim]);
+ return new ArrayFactoryJava.Int(SampleSystem.ofSize(dim), new
int[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNlTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNlTest.java
index f813c88cc4..4eff336bbe 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNlTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNlTest.java
@@ -30,7 +30,7 @@ public class ArrayNlTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Long(SampleSystem.ofSize(dim), new
long[length*dim]);
+ return new ArrayFactoryJava.Long(SampleSystem.ofSize(dim), new
long[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNsTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNsTest.java
index 0fb4ec4e41..cc3eabee37 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNsTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNsTest.java
@@ -30,7 +30,7 @@ public class ArrayNsTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.Short(SampleSystem.ofSize(dim), new
short[length*dim]);
+ return new ArrayFactoryJava.Short(SampleSystem.ofSize(dim), new
short[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNubTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNubTest.java
index 21549b339c..74fcea1190 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNubTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNubTest.java
@@ -30,7 +30,7 @@ public class ArrayNubTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.UByte(SampleSystem.ofSize(dim), new
byte[length*dim]);
+ return new ArrayFactoryJava.UByte(SampleSystem.ofSize(dim), new
byte[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNuiTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNuiTest.java
index 024100c989..a23253e2f9 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNuiTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNuiTest.java
@@ -30,7 +30,7 @@ public class ArrayNuiTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.UInt(SampleSystem.ofSize(dim), new
int[length*dim]);
+ return new ArrayFactoryJava.UInt(SampleSystem.ofSize(dim), new
int[length*dim]);
}
}
diff --git
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNusTest.java
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNusTest.java
index 5baae69523..5ed96df658 100644
---
a/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNusTest.java
+++
b/incubator/src/org.apache.sis.geometry/test/org/apache/sis/geometries/math/ArrayNusTest.java
@@ -30,7 +30,7 @@ public class ArrayNusTest extends AbstractArrayTest {
@Override
protected Array create(int dim, int length) {
- return new JavaFactory.UShort(SampleSystem.ofSize(dim), new
short[length*dim]);
+ return new ArrayFactoryJava.UShort(SampleSystem.ofSize(dim), new
short[length*dim]);
}
}