Skip to content

Commit

Permalink
Start working on 1.22.0 with GeoTools 30
Browse files Browse the repository at this point in the history
  • Loading branch information
jericks committed Oct 25, 2023
1 parent a216a4e commit 58535bd
Show file tree
Hide file tree
Showing 77 changed files with 277 additions and 279 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<groupId>org.geoscript</groupId>
<artifactId>geoscript-groovy</artifactId>
<packaging>jar</packaging>
<version>1.21.0</version>
<version>1.22.0-SNAPSHOT</version>
<properties>
<gt.version>29.2</gt.version>
<gt.version>30.0</gt.version>
<jts.version>1.19.0</jts.version>
<groovy.version>4.0.13</groovy.version>
<groovy.version>4.0.15</groovy.version>
</properties>
<dependencies>
<dependency>
Expand Down
32 changes: 16 additions & 16 deletions src/main/groovy/geoscript/GeoScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ class GeoScript {
*/
static Object wrap(Object obj) {
// SimpleFeature -> Feature
if (obj instanceof org.opengis.feature.simple.SimpleFeature) {
return new Feature(obj as org.opengis.feature.simple.SimpleFeature)
if (obj instanceof org.geotools.api.feature.simple.SimpleFeature) {
return new Feature(obj as org.geotools.api.feature.simple.SimpleFeature)
}
// SimpleFeatureType -> Schema
else if (obj instanceof org.opengis.feature.simple.SimpleFeatureType) {
return new Schema(obj as org.opengis.feature.simple.SimpleFeatureType)
else if (obj instanceof org.geotools.api.feature.simple.SimpleFeatureType) {
return new Schema(obj as org.geotools.api.feature.simple.SimpleFeatureType)
}
// JTS Geometry -> Geometry
else if (obj instanceof org.locationtech.jts.geom.Geometry) {
Expand All @@ -184,40 +184,40 @@ class GeoScript {
return new Bounds(obj as org.geotools.geometry.jts.ReferencedEnvelope)
}
// GeoTools Expression -> Expression
else if (obj instanceof org.opengis.filter.expression.Expression) {
return new Expression(obj as org.opengis.filter.expression.Expression)
else if (obj instanceof org.geotools.api.filter.expression.Expression) {
return new Expression(obj as org.geotools.api.filter.expression.Expression)
}
// GeoTools Filter -> Filter
else if (obj instanceof org.opengis.filter.Filter) {
return new Filter(obj as org.opengis.filter.Filter)
else if (obj instanceof org.geotools.api.filter.Filter) {
return new Filter(obj as org.geotools.api.filter.Filter)
}
// FeatureCollection -> Cursor
else if (obj instanceof org.geotools.feature.FeatureCollection) {
return new Cursor(obj as org.geotools.feature.FeatureCollection)
}
// FeatureSource -> Layer
else if (obj instanceof org.geotools.data.FeatureSource) {
return new Layer(obj as org.geotools.data.FeatureSource)
else if (obj instanceof org.geotools.api.data.FeatureSource) {
return new Layer(obj as org.geotools.api.data.FeatureSource)
}
/*// GeoTools Process -> Process
else if (obj instanceof org.geotools.process.Process) {
return new Process((obj as org.geotools.process.Process)
}*/
// CoordinateReferenceSystem -> Projection
else if (obj instanceof org.opengis.referencing.crs.CoordinateReferenceSystem) {
return new Projection(obj as org.opengis.referencing.crs.CoordinateReferenceSystem)
else if (obj instanceof org.geotools.api.referencing.crs.CoordinateReferenceSystem) {
return new Projection(obj as org.geotools.api.referencing.crs.CoordinateReferenceSystem)
}
// DefaultEllipsoid -> Geodetic
else if (obj instanceof org.geotools.referencing.datum.DefaultEllipsoid) {
return new Geodetic(obj as org.geotools.referencing.datum.DefaultEllipsoid)
}
// DataStore -> Workspace
else if (obj instanceof org.geotools.data.DataStore) {
return new Workspace(obj as org.geotools.data.DataStore)
else if (obj instanceof org.geotools.api.data.DataStore) {
return new Workspace(obj as org.geotools.api.data.DataStore)
}
// GridCoverage -> Raster
else if (obj instanceof org.opengis.coverage.grid.GridCoverage) {
def grid = obj as org.opengis.coverage.grid.GridCoverage
else if (obj instanceof org.geotools.api.coverage.grid.GridCoverage) {
def grid = obj as org.geotools.api.coverage.grid.GridCoverage
return new Raster(grid)
}
// GridFormat -> Format
Expand Down
14 changes: 7 additions & 7 deletions src/main/groovy/geoscript/carto/LegendItem.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import geoscript.layer.Renderable
import geoscript.style.ColorMap
import geoscript.style.Style
import org.geotools.filter.text.cql2.CQL
import org.geotools.styling.Rule
import org.geotools.styling.StyleFactory
import org.geotools.api.style.Rule
import org.geotools.api.style.StyleFactory
import org.geotools.styling.StyleFactoryImpl
import org.opengis.filter.Filter
import org.geotools.api.filter.Filter

import java.awt.Color
import java.awt.Font
Expand Down Expand Up @@ -286,7 +286,7 @@ class LegendItem extends Item {
this
}

private int countRules(org.opengis.style.Style style) {
private int countRules(org.geotools.api.style.Style style) {
int numberOfRules = 0
style.featureTypeStyles().each { def fts ->
fts.rules().each { def rule ->
Expand All @@ -297,12 +297,12 @@ class LegendItem extends Item {
}

private static class SLDStyle implements Style {
private final org.geotools.styling.Style style
private final org.geotools.api.style.Style style
private final static StyleFactory styleFactory = new StyleFactoryImpl()
SLDStyle(org.geotools.styling.Style style) {
SLDStyle(org.geotools.api.style.Style style) {
this.style = style
}
org.geotools.styling.Style getGtStyle() {
org.geotools.api.style.Style getGtStyle() {
style
}
static SLDStyle fromRule(Rule rule) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/geoscript/feature/Feature.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import geoscript.geom.Bounds
import geoscript.geom.Geometry
import geoscript.layer.Layer
import org.geotools.feature.simple.SimpleFeatureBuilder
import org.opengis.feature.simple.SimpleFeature
import org.geotools.api.feature.simple.SimpleFeature

/**
* A Feature contains a set of named attributes with values.
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/geoscript/feature/Schema.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package geoscript.feature

import org.geotools.feature.simple.SimpleFeatureBuilder
import org.opengis.feature.simple.SimpleFeatureType
import org.opengis.feature.type.AttributeDescriptor
import org.opengis.feature.type.GeometryDescriptor
import org.geotools.api.feature.simple.SimpleFeatureType
import org.geotools.api.feature.type.AttributeDescriptor
import org.geotools.api.feature.type.GeometryDescriptor
import org.geotools.feature.NameImpl
import org.geotools.feature.simple.SimpleFeatureTypeBuilder
import org.geotools.data.DataUtilities
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/geoscript/feature/io/GmlReader.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.geotools.xsd.Parser
import org.geotools.gml2.GMLConfiguration as GML2
import org.geotools.gml3.GMLConfiguration as GML3
import org.geotools.gml3.v3_2.GMLConfiguration as GML32
import org.opengis.feature.simple.SimpleFeature
import org.geotools.api.feature.simple.SimpleFeature

/**
* Read a Feature from a GML String.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package geoscript.feature.io

import geoscript.feature.Schema
import org.geotools.data.DataUtilities
import org.opengis.feature.simple.SimpleFeatureType
import org.geotools.api.feature.simple.SimpleFeatureType

/**
* Read a Schema from a simple String. This implementation uses GeoTools
Expand Down
22 changes: 11 additions & 11 deletions src/main/groovy/geoscript/filter/Expression.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package geoscript.filter

import geoscript.GeoScript
import org.opengis.filter.expression.Expression as GtExpression
import org.geotools.api.filter.expression.Expression as GtExpression
import org.geotools.factory.CommonFactoryFinder
import org.opengis.filter.FilterFactory
import org.geotools.api.filter.FilterFactory
import org.geotools.filter.text.cql2.CQL

/**
Expand Down Expand Up @@ -55,12 +55,12 @@ class Expression {
* @return The value
*/
def getValue() {
if (expr instanceof org.opengis.filter.expression.Literal) {
return (expr as org.opengis.filter.expression.Literal).value
} else if (expr instanceof org.opengis.filter.expression.Function) {
return new Function(expr as org.opengis.filter.expression.Function)
} else if (expr instanceof org.opengis.filter.expression.PropertyName) {
return (expr as org.opengis.filter.expression.PropertyName).propertyName
if (expr instanceof org.geotools.api.filter.expression.Literal) {
return (expr as org.geotools.api.filter.expression.Literal).value
} else if (expr instanceof org.geotools.api.filter.expression.Function) {
return new Function(expr as org.geotools.api.filter.expression.Function)
} else if (expr instanceof org.geotools.api.filter.expression.PropertyName) {
return (expr as org.geotools.api.filter.expression.PropertyName).propertyName
} else {
return expr
}
Expand Down Expand Up @@ -90,11 +90,11 @@ class Expression {
*/
static Expression fromCQL(String cql) {
def e = CQL.toExpression(cql)
if (e instanceof org.opengis.filter.expression.Literal) {
if (e instanceof org.geotools.api.filter.expression.Literal) {
return new Expression(e)
} else if (e instanceof org.opengis.filter.expression.Function) {
} else if (e instanceof org.geotools.api.filter.expression.Function) {
return new Function(e)
} else if (e instanceof org.opengis.filter.expression.PropertyName) {
} else if (e instanceof org.geotools.api.filter.expression.PropertyName) {
return new Property(e)
} else {
return new Expression(e)
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/geoscript/filter/Expressions.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package geoscript.filter

import geoscript.feature.Field
import org.opengis.filter.expression.Function as GtFunction
import org.opengis.filter.expression.Expression as GtExpression
import org.geotools.api.filter.expression.Function as GtFunction
import org.geotools.api.filter.expression.Expression as GtExpression

/**
* The Expressions class holds static methods for creating new Expressions ({@link Expression}, {@link Color}, {@link Function}, {@link Property}).
Expand Down
14 changes: 7 additions & 7 deletions src/main/groovy/geoscript/filter/Filter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import geoscript.geom.Bounds
import geoscript.geom.Geometry
import geoscript.feature.Feature
import org.geotools.filter.visitor.SimplifyingFilterVisitor
import org.opengis.filter.Filter as GTFilter
import org.geotools.api.filter.Filter as GTFilter
import org.geotools.filter.text.ecql.ECQL
import org.geotools.xsd.Parser
import org.geotools.xsd.Encoder
Expand All @@ -14,7 +14,7 @@ import org.geotools.filter.v1_1.OGCConfiguration as OGCConfiguration11
import org.geotools.filter.v1_1.OGC as OGC11
import org.geotools.factory.CommonFactoryFinder
import org.geotools.util.factory.GeoTools
import org.opengis.filter.FilterFactory2
import org.geotools.api.filter.FilterFactory

/**
* A Filter is a predicate or constraint used to match or filter {@link geoscript.feature.Feature Feature} objects.
Expand All @@ -38,11 +38,11 @@ class Filter {
/**
* The GeoTools FilterFactory
*/
FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(GeoTools.defaultHints)
FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.defaultHints)

/**
* Create a new Filter wrapping a GeoTools Filter
* @param filter The org.opengis.filter.Filter
* @param filter The org.geotools.api.filter.Filter
*/
Filter(GTFilter filter) {
this.filter = filter
Expand Down Expand Up @@ -227,7 +227,7 @@ class Filter {
* @return A Filter
*/
static Filter equals(String field, Object value) {
FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(GeoTools.defaultHints)
FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.defaultHints)
new Filter(factory.equals(factory.property(field), factory.literal(value)))
}

Expand Down Expand Up @@ -291,7 +291,7 @@ class Filter {
* @return A Filter
*/
static Filter id(String id) {
FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(GeoTools.defaultHints)
FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.defaultHints)
new Filter(factory.id(factory.featureId(id)))
}

Expand All @@ -301,7 +301,7 @@ class Filter {
* @return A Filter
*/
static Filter ids(List ids) {
FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(GeoTools.defaultHints)
FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.defaultHints)
new Filter(factory.id(ids.collect{ factory.featureId(it) } as Set))
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/groovy/geoscript/filter/Function.groovy
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package geoscript.filter

import org.opengis.filter.expression.Function as GtFunction
import org.opengis.filter.expression.Expression as GtExpression
import org.geotools.api.filter.expression.Function as GtFunction
import org.geotools.api.filter.expression.Expression as GtExpression
import org.geotools.factory.CommonFactoryFinder
import org.geotools.util.factory.FactoryIteratorProvider
import org.geotools.util.factory.GeoTools
import org.geotools.filter.FunctionExpressionImpl
import org.geotools.filter.FunctionFactory
import org.opengis.feature.type.Name
import org.opengis.filter.expression.Literal
import org.geotools.api.feature.type.Name
import org.geotools.api.filter.expression.Literal
import org.geotools.feature.NameImpl
import org.opengis.filter.capability.FunctionName
import org.geotools.api.filter.capability.FunctionName

/**
* A GeoScript Function either wraps an existing GeoTools Function or an CQL String.
Expand All @@ -31,7 +31,7 @@ class Function extends Expression {
/**
* The GeoTools CommonFactoryFinder for finding GeoTools Functions
*/
private static def ff = CommonFactoryFinder.getFilterFactory2(null)
private static def ff = CommonFactoryFinder.getFilterFactory(null)

/**
* The GeoTools Function
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/geoscript/filter/ProcessFunction.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProcessFunction extends Function {
* @param process The GeoScript Process
* @param functions A variable List of Functions
*/
private static org.opengis.filter.expression.Function createProcessFunction(geoscript.process.Process process, Function... functions) {
private static org.geotools.api.filter.expression.Function createProcessFunction(geoscript.process.Process process, Function... functions) {
def pff = new org.geotools.process.function.ProcessFunctionFactory()
def names = process.name.split(":")
def nm = new NameImpl(names[0], names[1])
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/geoscript/filter/Property.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package geoscript.filter

import geoscript.feature.Field
import org.opengis.filter.expression.PropertyName
import org.geotools.api.filter.expression.PropertyName

/**
* Property is an {@link Expression} that is a {@link geoscript.feature.Field Field} value
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/geoscript/layer/Band.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package geoscript.layer

import org.geotools.coverage.GridSampleDimension
import org.geotools.coverage.TypeMap
import org.opengis.coverage.SampleDimensionType
import org.geotools.api.coverage.SampleDimensionType
import javax.measure.Unit
import java.awt.image.DataBuffer
import org.opengis.coverage.SampleDimension
import org.geotools.api.coverage.SampleDimension

/**
* A Band of Raster Data that represents a single band/channel/layer.
Expand Down
8 changes: 4 additions & 4 deletions src/main/groovy/geoscript/layer/Cursor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.geotools.data.store.ReprojectingFeatureIterator
import org.geotools.feature.FeatureIterator
import org.geotools.feature.FeatureTypes
import org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer
import org.opengis.feature.simple.SimpleFeature
import org.opengis.feature.simple.SimpleFeatureType
import org.geotools.api.feature.simple.SimpleFeature
import org.geotools.api.feature.simple.SimpleFeatureType
import org.geotools.feature.FeatureCollection
import org.geotools.data.store.MaxFeaturesIterator
import org.geotools.data.sort.SortedFeatureIterator
import org.opengis.filter.sort.SortBy
import org.geotools.api.filter.sort.SortBy

/**
* A Cursor is a Iterator over a Feature objects.
Expand Down Expand Up @@ -84,7 +84,7 @@ class Cursor implements Iterator {
long max = options.max as long
if (!options.containsKey("sort")
&& layer
&& layer.workspace.format in ['Directory', 'org.geotools.data.shapefile.ShapefileDataStore', 'org.geotools.data.directory.DirectoryDataStore']) {
&& layer.workspace.format in ['Directory', 'org.geotools.api.data.shapefile.ShapefileDataStore', 'org.geotools.api.data.directory.DirectoryDataStore']) {
this.iter = new SortedFeatureIterator(this.iter, col.schema, [SortBy.NATURAL_ORDER] as SortBy[], Integer.MAX_VALUE)
}
this.iter = new MaxFeaturesIterator<SimpleFeature>(this.iter, start, max)
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/geoscript/layer/Format.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import org.geotools.coverage.grid.io.GridFormatFinder
import org.geotools.coverage.grid.io.UnknownFormat
import org.geotools.util.factory.GeoTools
import org.geotools.util.factory.Hints
import org.opengis.coverage.grid.GridCoverageReader
import org.opengis.parameter.GeneralParameterValue
import org.opengis.parameter.ParameterValueGroup
import org.geotools.api.coverage.grid.GridCoverageReader
import org.geotools.api.parameter.GeneralParameterValue
import org.geotools.api.parameter.ParameterValueGroup

import java.awt.*
import java.util.List
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/geoscript/layer/Graticule.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import geoscript.feature.Schema
import geoscript.geom.Bounds
import geoscript.workspace.Memory
import geoscript.workspace.Workspace
import org.geotools.data.FeatureSource
import org.geotools.data.simple.SimpleFeatureSource
import org.geotools.api.data.FeatureSource
import org.geotools.api.data.SimpleFeatureSource
import org.geotools.grid.GridElement
import org.geotools.grid.GridFeatureBuilder
import org.geotools.grid.Grids
Expand Down
Loading

0 comments on commit 58535bd

Please sign in to comment.