Skip to content

Add Support for GeoTools SimpleFeature - #1495

Merged
lossyrob merged 17 commits into
locationtech:masterfrom
jamesmcclain:feature/jwm/SimpleFeature
Jul 8, 2016
Merged

lossyrob merged 17 commits into
locationtech:masterfrom
jamesmcclain:feature/jwm/SimpleFeature

Conversation

@jamesmcclain

@jamesmcclain jamesmcclain commented May 23, 2016 •

Copy link
Copy Markdown
Member

In this pull request, support is added for converting GeoTools SimpleFeatures into Geotrellis Feature objects and vice-versa.

Still Needs

@jamesmcclain
jamesmcclain force-pushed the feature/jwm/SimpleFeature branch 2 times, most recently from e0ad08c to fe68ed3 Compare May 24, 2016 20:31
@jamesmcclain jamesmcclain changed the title [WiP] Add Support for GeoTools SimpleFeature Add Support for GeoTools SimpleFeature May 24, 2016
Comment thread geotools/build.sbt Outdated
"org.geotools" % "gt-coverage" % Version.geotools,
"org.geotools" % "gt-geotiff" % Version.geotools,
"org.geotools" % "gt-epsg-hsql" % Version.geotools,
"org.apache.spark" %% "spark-core" % Version.spark % "provided",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the first few commits of this PR were taken from my other GeoTools-related PR. When the GridCoverage2D stuff that Rob is working on goes in, I will rebase and this will go away.

@jamesmcclain
jamesmcclain force-pushed the feature/jwm/SimpleFeature branch from fe68ed3 to 4aa2876 Compare May 26, 2016 15:22
@jamesmcclain
jamesmcclain force-pushed the feature/jwm/SimpleFeature branch 4 times, most recently from 7b28582 to 1746e54 Compare June 13, 2016 14:15
@lossyrob

Copy link
Copy Markdown
Member

This API should be refactored to follow the ToGridCoverage2DMethods design pattern, to provide this functionality as implicit methods, and to provide better usability.

Client side view of the API should be e.g.

val point: Point = ???
val crs: CRS = ???
val data: Map[(String, Any)] = ???

point.toSimpleFeature()
point.toSimpleFeature(crs)
point.toSimpleFeature(crs, data)
point.toSimpleFeature(data)

val simpleFeature: SimpleFeature = ???
val point: Point = simpleFeature.toGeometry[Point]
val geom: Geometry = simpleFeature.toGeometry[Geometry]
val pointFeature: PointFeature[Map[String, Object]] = simpleFeature.toFeature[Point]

// this opens the door for an implicit that converts the map to a case class, e.g.
case class Foo(x: Int, y: String)
implicit def mapToFoo(map: Map[String, Object]): Foo = ???

val pointFeature: PointFeature[Foo] = simpleFeature.toFeature[Point, Foo](mapToFoo) // mapToFoo implicit param

@jamesmcclain

Copy link
Copy Markdown
Member Author

Okay, I will see if I can put those changes in soon.

@jamesmcclain
jamesmcclain force-pushed the feature/jwm/SimpleFeature branch from 1746e54 to a4cc264 Compare July 1, 2016 14:23
@jamesmcclain

Copy link
Copy Markdown
Member Author

I believe that all comments prior to this one have been addressed.

}
}

def apply(simpleFeature: SimpleFeature): Feature[Geometry, immutable.Map[String, Object]] = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have this typed on [G <: Geometry: ClassTag] then use a combination of

https://github.com/geotrellis/geotrellis/blob/master/vector/src/main/scala/geotrellis/vector/Geometry.scala#L81

and

https://github.com/geotrellis/geotrellis/blob/master/vector/src/main/scala/geotrellis/vector/Geometry.scala#L105

To return the correct type.

Then the asInstanceOf cast below gets pushed down into the moment we translate from a JTS geometry.

We could call SimpleFeatureToFeature[Geometry] to keep the most generic type

@jamesmcclain

Copy link
Copy Markdown
Member Author

I believe that all comments prior to this one have been addressed.

}
}

def apply[G <: Geometry : ClassTag](simpleFeature: SimpleFeature): Feature[G, immutable.Map[String, Object]] = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about our ability to pull off a roundtrip without an inverse of the transmute function defined for the Feature -> SimpleFeature translation

@jamesmcclain
jamesmcclain force-pushed the feature/jwm/SimpleFeature branch from 519c7a4 to 6868341 Compare July 8, 2016 15:27
@jamesmcclain

Copy link
Copy Markdown
Member Author

Map[String, Object] has been changed to Map[String, AnyRef]

@lossyrob

lossyrob commented Jul 8, 2016

Copy link
Copy Markdown
Member

+1

@lossyrob
lossyrob merged commit 374e6c1 into locationtech:master Jul 8, 2016
@jamesmcclain
jamesmcclain deleted the feature/jwm/SimpleFeature branch July 8, 2016 17:03
@lossyrob lossyrob added this to the 1.0 milestone Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants