Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geo Tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Genesys PGR
Geo Tools
Commits
f5469f9a
Commit
f5469f9a
authored
Apr 19, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make shape file source folder configurable
parent
a3f21dcf
Pipeline
#5202
passed with stage
in 1 minute and 10 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
30 deletions
+20
-30
genesys-geotools/src/main/java/org/genesys/geotools/service/ShapefileUtils.java
...ain/java/org/genesys/geotools/service/ShapefileUtils.java
+3
-4
genesys-geotools/src/main/java/org/genesys/geotools/service/impl/CountryOfOriginServiceImpl.java
...sys/geotools/service/impl/CountryOfOriginServiceImpl.java
+9
-2
genesys-geotools/src/main/java/org/genesys/geotools/service/impl/LandOrSeaServiceImpl.java
...g/genesys/geotools/service/impl/LandOrSeaServiceImpl.java
+8
-24
No files found.
genesys-geotools/src/main/java/org/genesys/geotools/service/ShapefileUtils.java
View file @
f5469f9a
...
...
@@ -56,12 +56,11 @@ public class ShapefileUtils {
* @throws MalformedURLException the malformed url exception
* @throws IOException Signals that an I/O exception has occurred.
*/
public
static
DataStore
openShapeFile
(
final
String
shapeFilePath
)
throws
MalformedURLException
,
IOException
{
public
static
DataStore
openShapeFile
(
final
File
shapeFile
)
throws
MalformedURLException
,
IOException
{
final
File
file
=
new
File
(
"data"
,
shapeFilePath
);
final
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"url"
,
f
ile
.
toURI
().
toURL
());
System
.
err
.
println
(
f
ile
.
toURI
().
toURL
());
map
.
put
(
"url"
,
shapeF
ile
.
toURI
().
toURL
());
System
.
err
.
println
(
shapeF
ile
.
toURI
().
toURL
());
final
DataStore
dataStore
=
DataStoreFinder
.
getDataStore
(
map
);
return
dataStore
;
...
...
genesys-geotools/src/main/java/org/genesys/geotools/service/impl/CountryOfOriginServiceImpl.java
View file @
f5469f9a
...
...
@@ -16,6 +16,7 @@
package
org.genesys.geotools.service.impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.util.concurrent.ExecutionException
;
...
...
@@ -74,6 +75,12 @@ public class CountryOfOriginServiceImpl implements CountryOfOriginService {
/** The debug. */
private
final
boolean
debug
=
false
;
private
String
dataFolderPath
=
"data"
;
public
void
setDataFolderPath
(
String
dataFolderPath
)
{
this
.
dataFolderPath
=
dataFolderPath
;
}
static
{
try
{
// Initialize stuff
...
...
@@ -93,8 +100,8 @@ public class CountryOfOriginServiceImpl implements CountryOfOriginService {
public
void
afterPropertiesSet
()
throws
MalformedURLException
,
IOException
{
// http://www.gadm.org/version2
// Use "six dissolved layers"
final
DataStore
dataStoreAdm0
=
ShapefileUtils
.
openShapeFile
(
"TM_WORLD_BORDERS-0.3.shp"
);
final
DataStore
dataStoreAdm0X
=
ShapefileUtils
.
openShapeFile
(
"gadm28_adm1.shp"
);
final
DataStore
dataStoreAdm0
=
ShapefileUtils
.
openShapeFile
(
new
File
(
dataFolderPath
,
"TM_WORLD_BORDERS-0.3.shp"
)
);
final
DataStore
dataStoreAdm0X
=
ShapefileUtils
.
openShapeFile
(
new
File
(
dataFolderPath
,
"gadm28_adm1.shp"
)
);
sourceAdmin0
=
dataStoreAdm0
.
getFeatureSource
(
dataStoreAdm0
.
getTypeNames
()[
0
]);
sourceAdmin0X
=
dataStoreAdm0X
.
getFeatureSource
(
dataStoreAdm0X
.
getTypeNames
()[
0
]);
...
...
genesys-geotools/src/main/java/org/genesys/geotools/service/impl/LandOrSeaServiceImpl.java
View file @
f5469f9a
...
...
@@ -19,8 +19,6 @@ package org.genesys.geotools.service.impl;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -28,7 +26,6 @@ import org.genesys.geotools.service.LandOrSeaService;
import
org.genesys.geotools.service.LonLatCacheKey
;
import
org.genesys.geotools.service.ShapefileUtils
;
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
;
...
...
@@ -74,6 +71,12 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
/** The classifier cache. */
private
LoadingCache
<
LonLatCacheKey
,
String
>
classifierCache
;
private
String
dataFolderPath
=
"data"
;
public
void
setDataFolderPath
(
String
dataFolderPath
)
{
this
.
dataFolderPath
=
dataFolderPath
;
}
/**
* After properties set.
*
...
...
@@ -83,11 +86,11 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
public
void
afterPropertiesSet
()
throws
MalformedURLException
,
IOException
{
// http://openstreetmapdata.com/data/land-polygons
// Use "split large polygons"
final
DataStore
dataStoreLand
=
openShapeFile
(
"land_polygons.shp"
);
final
DataStore
dataStoreLand
=
ShapefileUtils
.
openShapeFile
(
new
File
(
dataFolderPath
,
"land_polygons.shp"
)
);
// http://openstreetmapdata.com/data/water-polygons
// Use "split large polygons"
final
DataStore
dataStoreWater
=
openShapeFile
(
"water_polygons.shp"
);
final
DataStore
dataStoreWater
=
ShapefileUtils
.
openShapeFile
(
new
File
(
dataFolderPath
,
"water_polygons.shp"
)
);
sourceLand
=
dataStoreLand
.
getFeatureSource
(
dataStoreLand
.
getTypeNames
()[
0
]);
sourceWater
=
dataStoreWater
.
getFeatureSource
(
dataStoreWater
.
getTypeNames
()[
0
]);
...
...
@@ -237,23 +240,4 @@ public class LandOrSeaServiceImpl implements LandOrSeaService {
}
}
/**
* Open shape file.
*
* @param shapeFilePath the shape file path
* @return the data store
* @throws MalformedURLException the malformed url exception
* @throws IOException Signals that an I/O exception has occurred.
*/
private
DataStore
openShapeFile
(
final
String
shapeFilePath
)
throws
MalformedURLException
,
IOException
{
final
File
file
=
new
File
(
"data"
,
shapeFilePath
);
final
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"url"
,
file
.
toURI
().
toURL
());
LOG
.
debug
(
"Opening shapeFile at {}"
,
file
.
toURI
().
toURL
());
final
DataStore
dataStore
=
DataStoreFinder
.
getDataStore
(
map
);
return
dataStore
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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