Skip to content

Commit 4f92c50

Browse files
author
Philip (flip) Kromer
committed
Adding Interfaces to families of operators; permits much cleaner UDFs
* New interface IOperatorAWithB for (geom, geom) -> geom * Applied it to Intersection, Difference, SymmetricDifference, and Union More to come.
1 parent da180fd commit 4f92c50

5 files changed

Lines changed: 53 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 1995-2013 Esri
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
For additional information, contact:
17+
Environmental Systems Research Institute, Inc.
18+
Attn: Contracts Dept
19+
380 New York Street
20+
Redlands, California, USA 92373
21+
22+
email: contracts@esri.com
23+
*/
24+
package com.esri.core.geometry;
25+
26+
import com.esri.core.geometry.Geometry;
27+
import com.esri.core.geometry.SpatialReference;
28+
import com.esri.core.geometry.ProgressTracker;
29+
30+
/**
31+
* Interface for operators that act on two geometries to produce a new geometry as result.
32+
*/
33+
public interface IOperatorAWithB {
34+
35+
/**
36+
* Operation on two geometries, returning a third. Examples include
37+
* Intersection, Difference, and so forth.
38+
*
39+
* @param geom1 and geom2 are the geometry instances to be operated on.
40+
*
41+
*/
42+
public Geometry execute(Geometry geom1, Geometry geom2,
43+
SpatialReference sr, ProgressTracker progressTracker);
44+
45+
}

src/main/java/com/esri/core/geometry/OperatorDifference.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
package com.esri.core.geometry;
2626

2727
import com.esri.core.geometry.Operator.Type;
28+
import com.esri.core.geometry.IOperatorAWithB;
2829

2930
/**
3031
* Difference of geometries.
3132
*/
32-
public abstract class OperatorDifference extends Operator {
33+
public abstract class OperatorDifference extends Operator implements IOperatorAWithB {
3334

3435
@Override
3536
public Type getType() {

src/main/java/com/esri/core/geometry/OperatorIntersection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
package com.esri.core.geometry;
2626

2727
import com.esri.core.geometry.Operator.Type;
28+
import com.esri.core.geometry.IOperatorAWithB;
2829

2930
/**
3031
*Intersection of geometries by a given geometry.
3132
*/
32-
public abstract class OperatorIntersection extends Operator {
33+
public abstract class OperatorIntersection extends Operator implements IOperatorAWithB {
3334
@Override
3435
public Type getType() {
3536
return Type.Intersection;

src/main/java/com/esri/core/geometry/OperatorSymmetricDifference.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
package com.esri.core.geometry;
2525

2626
import com.esri.core.geometry.Operator.Type;
27+
import com.esri.core.geometry.IOperatorAWithB;
2728

2829
/**
2930
* Symmetric difference (XOR) operation between geometries.
3031
*
3132
*/
32-
public abstract class OperatorSymmetricDifference extends Operator {
33+
public abstract class OperatorSymmetricDifference extends Operator implements IOperatorAWithB {
3334
@Override
3435
public Type getType() {
3536
return Type.Difference;

src/main/java/com/esri/core/geometry/OperatorUnion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
package com.esri.core.geometry;
2626

2727
import com.esri.core.geometry.Operator.Type;
28+
import com.esri.core.geometry.IOperatorAWithB;
2829

2930
/**
3031
*
3132
* Union of geometries.
3233
*
3334
*/
34-
public abstract class OperatorUnion extends Operator {
35+
public abstract class OperatorUnion extends Operator implements IOperatorAWithB {
3536
@Override
3637
public Type getType() {
3738
return Type.Union;

0 commit comments

Comments
 (0)