Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Geo Tools
Commits
a26ad556
Commit
a26ad556
authored
Jan 22, 2016
by
Matija Obreza
Browse files
Debug print features near a location
parent
cb5b19ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys/geotools/LandOrSeaServiceImpl.java
View file @
a26ad556
...
...
@@ -12,6 +12,8 @@ import org.geotools.data.DataStore;
import
org.geotools.data.DataStoreFinder
;
import
org.geotools.data.FeatureSource
;
import
org.geotools.factory.CommonFactoryFinder
;
import
org.geotools.feature.FeatureCollection
;
import
org.geotools.feature.FeatureIterator
;
import
org.geotools.geometry.jts.JTSFactoryFinder
;
import
org.opengis.feature.simple.SimpleFeature
;
import
org.opengis.feature.simple.SimpleFeatureType
;
...
...
@@ -32,12 +34,13 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
private
static
final
FilterFactory2
ff
=
CommonFactoryFinder
.
getFilterFactory2
();
private
static
final
GeometryFactory
geometryFactory
=
JTSFactoryFinder
.
getGeometryFactory
();
private
FeatureSource
<
SimpleFeatureType
,
SimpleFeature
>
sourceLand
;
private
FeatureSource
<
SimpleFeatureType
,
SimpleFeature
>
sourceWater
;
private
LoadingCache
<
LonLatCacheKey
,
Boolean
>
waterCache
;
private
LoadingCache
<
LonLatCacheKey
,
String
>
classifierCache
;
private
boolean
debug
=
false
;
public
void
afterPropertiesSet
()
throws
MalformedURLException
,
IOException
{
// http://openstreetmapdata.com/data/land-polygons
...
...
@@ -89,7 +92,21 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
Filter
filterBuffered
=
ff
.
intersects
(
ff
.
property
(
"the_geom"
),
ff
.
literal
(
ShapefileUtils
.
getPointBuffer
(
longitude
,
latitude
,
allowedDistanceMargin
)));
if
(
sourceLand
.
getFeatures
(
filterBuffered
).
size
()
>
0
)
{
FeatureCollection
<
SimpleFeatureType
,
SimpleFeature
>
matchingFeatures
=
sourceLand
.
getFeatures
(
filterBuffered
);
if
(
matchingFeatures
.
size
()
>
0
)
{
if
(
debug
)
{
try
(
FeatureIterator
<
SimpleFeature
>
features
=
matchingFeatures
.
features
())
{
while
(
features
.
hasNext
())
{
SimpleFeature
feature
=
features
.
next
();
System
.
err
.
print
(
feature
.
getID
());
System
.
err
.
print
(
": "
);
System
.
err
.
println
(
feature
.
getDefaultGeometryProperty
().
getValue
());
System
.
err
.
println
(
"Attrs: "
+
feature
.
getAttributes
());
}
}
}
return
"Coastal"
;
}
else
{
return
"Water"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment