Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Geo Tools
Commits
3e076f58
Commit
3e076f58
authored
Jan 20, 2016
by
Matija Obreza
Browse files
CLI
parent
ee8f29f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
3e076f58
...
...
@@ -21,8 +21,14 @@ as the jar file of this application. You should now have three files in this dir
landorsea.jar
jai
creates an AWT window. Run in headless mode:
JAI library
creates an AWT window. Run in headless mode:
java -Djava.awt.headless=true -jar landorsea.jar
Test.
= TODO List
*
Accept CSV or Excel file as input source
*
Generate HTML report
*
For "Water" entries, report distance to closest land.
src/main/java/org/genesys/geotools/LandOrSeaCLI.java
0 → 100644
View file @
3e076f58
package
org.genesys.geotools
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
LandOrSeaCLI
{
public
static
void
main
(
String
arg
[])
throws
Exception
{
LandOrSeaServiceImpl
landOrSeaService
=
new
LandOrSeaServiceImpl
();
landOrSeaService
.
afterPropertiesSet
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
Pattern
pattern
=
Pattern
.
compile
(
"^(\\-?\\d*\\.?\\d*)[ \\t,]+(\\-?\\d*\\.?\\d*)$"
);
System
.
err
.
println
(
"Expects input rows in format: Latitude\tLongitude"
);
System
.
err
.
println
(
"Enter 'q' to quit."
);
System
.
out
.
println
(
"Latitude\tLongitude\tResult"
);
String
input
=
null
;
do
{
input
=
br
.
readLine
();
Matcher
matcher
=
pattern
.
matcher
(
input
);
if
(
matcher
.
find
())
{
float
latitude
=
Float
.
parseFloat
(
matcher
.
group
(
1
).
replace
(
","
,
"."
));
float
longitude
=
Float
.
parseFloat
(
matcher
.
group
(
2
).
replace
(
","
,
"."
));
if
(
landOrSeaService
.
isOnLand
(
longitude
,
latitude
,
200
))
{
System
.
out
.
println
(
latitude
+
", "
+
longitude
+
", Land"
);
}
else
{
System
.
out
.
println
(
latitude
+
", "
+
longitude
+
", Water"
);
}
}
else
{
System
.
err
.
println
(
"Invalid format: "
+
input
);
}
}
while
(
input
==
null
||
!
"q"
.
equals
(
input
));
}
}
src/
test
/java/org/genesys/geotools/Quickstart.java
→
src/
main
/java/org/genesys/geotools/
gui/
Quickstart.java
View file @
3e076f58
package
org.genesys.geotools
;
package
org.genesys.geotools.gui
;
import
java.io.File
;
import
org.geotools.data.FileDataStore
;
...
...
@@ -13,36 +14,38 @@ import org.geotools.swing.JMapFrame;
import
org.geotools.swing.data.JFileDataStoreChooser
;
/**
* Prompts the user for a shapefile and displays the contents on the screen in a map frame.
* Prompts the user for a shapefile and displays the contents on the screen in a
* map frame.
* <p>
* This is the GeoTools Quickstart application used in documentationa and tutorials. *
* This is the GeoTools Quickstart application used in documentationa and
* tutorials. *
*/
public
class
Quickstart
{
/**
* GeoTools Quickstart demo application. Prompts the user for a shapefile
and displays its
*
contents on the screen in a map frame
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// display a data store file chooser dialog for shapefiles
File
file
=
JFileDataStoreChooser
.
showOpenFile
(
"shp"
,
null
);
if
(
file
==
null
)
{
return
;
}
FileDataStore
store
=
FileDataStoreFinder
.
getDataStore
(
file
);
SimpleFeatureSource
featureSource
=
store
.
getFeatureSource
();
// Create a map content and add our shapefile to it
MapContent
map
=
new
MapContent
();
map
.
setTitle
(
"Quickstart"
);
Style
style
=
SLD
.
createSimpleStyle
(
featureSource
.
getSchema
());
Layer
layer
=
new
FeatureLayer
(
featureSource
,
style
);
map
.
addLayer
(
layer
);
// Now display the map
JMapFrame
.
showMap
(
map
);
}
/**
* GeoTools Quickstart demo application. Prompts the user for a shapefile
* and displays its
contents on the screen in a map frame
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// display a data store file chooser dialog for shapefiles
File
file
=
JFileDataStoreChooser
.
showOpenFile
(
"shp"
,
null
);
if
(
file
==
null
)
{
return
;
}
FileDataStore
store
=
FileDataStoreFinder
.
getDataStore
(
file
);
SimpleFeatureSource
featureSource
=
store
.
getFeatureSource
();
// Create a map content and add our shapefile to it
MapContent
map
=
new
MapContent
();
map
.
setTitle
(
"Quickstart"
);
Style
style
=
SLD
.
createSimpleStyle
(
featureSource
.
getSchema
());
Layer
layer
=
new
FeatureLayer
(
featureSource
,
style
);
map
.
addLayer
(
layer
);
// Now display the map
JMapFrame
.
showMap
(
map
);
}
}
\ No newline at end of file
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