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
U
Uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
Uploader
Commits
38eabe65
Commit
38eabe65
authored
Oct 31, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Milko build
parent
64076cb4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
169 additions
and
120 deletions
+169
-120
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
+160
-112
anno-gui/src/main/java/org/genesys2/anno/util/GeoUtils.java
anno-gui/src/main/java/org/genesys2/anno/util/GeoUtils.java
+6
-6
anno-gui/src/test/java/org/genesys2/anno/util/GeoUtilsTest.java
...ui/src/test/java/org/genesys2/anno/util/GeoUtilsTest.java
+3
-2
No files found.
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
View file @
38eabe65
This diff is collapsed.
Click to expand it.
anno-gui/src/main/java/org/genesys2/anno/util/GeoUtils.java
View file @
38eabe65
...
...
@@ -24,8 +24,8 @@ import org.apache.log4j.Logger;
public
class
GeoUtils
{
private
static
final
Logger
_log
=
Logger
.
getLogger
(
GeoUtils
.
class
);
private
static
final
Pattern
LATITUDE
=
Pattern
.
compile
(
"([\\d\\- ]{2})([\\d\\- ]{2})([\\d\\- ]{2})(N|S)"
);
private
static
final
Pattern
LONGITUDE
=
Pattern
.
compile
(
"([\\d\\- ]{3})([\\d\\- ]{2})([\\d\\- ]{2})(E|W)"
);
private
static
final
Pattern
LATITUDE
=
Pattern
.
compile
(
"([\\d\\- ]{2})([\\d\\- ]{2})([\\d\\- ]{2})(N|S)"
,
Pattern
.
CASE_INSENSITIVE
);
private
static
final
Pattern
LONGITUDE
=
Pattern
.
compile
(
"([\\d\\- ]{3})([\\d\\- ]{2})([\\d\\- ]{2})(E|W)"
,
Pattern
.
CASE_INSENSITIVE
);
/**
* Convert DDMMSS[NS] to decimal latitude
...
...
@@ -46,7 +46,7 @@ public class GeoUtils {
Matcher
m
=
LATITUDE
.
matcher
(
str
.
replace
(
'-'
,
'0'
).
replace
(
' '
,
'0'
));
if
(
m
.
matches
())
{
_log
.
trace
(
"Latitude "
+
str
+
" matches format DDMMSS[
EW
]"
);
_log
.
trace
(
"Latitude "
+
str
+
" matches format DDMMSS[
NS
]"
);
String
deg
=
m
.
group
(
1
);
String
min
=
m
.
group
(
2
);
String
sec
=
m
.
group
(
3
);
...
...
@@ -55,12 +55,12 @@ public class GeoUtils {
double
latitude
=
Double
.
parseDouble
(
deg
);
latitude
+=
Double
.
parseDouble
(
min
)
/
60.0
;
latitude
+=
Double
.
parseDouble
(
sec
)
/
60.0
/
60.0
;
latitude
*=
compass
.
equals
(
"N"
)
?
1.0
:
-
1.0
;
latitude
*=
compass
.
toUpperCase
().
equals
(
"N"
)
?
1.0
:
-
1.0
;
latitude
=
Math
.
round
(
latitude
*
100000.0
)
/
100000.0
;
return
latitude
;
}
else
{
_log
.
error
(
"Latitude "
+
str
+
" does not match format DDMMSS[EW]"
);
throw
new
CoordinateConversionException
(
"Latitude "
+
str
+
" does not match format DDMMSS[
EW
]"
);
throw
new
CoordinateConversionException
(
"Latitude "
+
str
+
" does not match format DDMMSS[
NS
]"
);
}
}
...
...
@@ -93,7 +93,7 @@ public class GeoUtils {
double
longitude
=
Double
.
parseDouble
(
deg
);
longitude
+=
Double
.
parseDouble
(
min
)
/
60.0
;
longitude
+=
Double
.
parseDouble
(
sec
)
/
60.0
/
60.0
;
longitude
*=
compass
.
equals
(
"E"
)
?
1.0
:
-
1.0
;
longitude
*=
compass
.
toUpperCase
().
equals
(
"E"
)
?
1.0
:
-
1.0
;
longitude
=
Math
.
round
(
longitude
*
100000.0
)
/
100000.0
;
return
longitude
;
}
else
{
...
...
anno-gui/src/test/java/org/genesys2/anno/util/GeoUtilsTest.java
View file @
38eabe65
...
...
@@ -15,6 +15,7 @@
*/
package
org.genesys2.anno.util
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
...
...
@@ -29,7 +30,7 @@ public class GeoUtilsTest {
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"000000N"
)
==
0.0
);
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"000000S"
)
==
-
0.0
);
assertT
rue
(
GeoUtils
.
toDecimalLatitude
(
"100000N"
)
==
10.0
);
assertT
hat
(
GeoUtils
.
toDecimalLatitude
(
"100000N"
),
is
(
10.0
)
);
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"100---N"
)
==
10.0
);
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"100000S"
)
==
-
10.0
);
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"000001N"
)
==
0.00028
);
...
...
@@ -37,7 +38,7 @@ public class GeoUtilsTest {
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"000010N"
)
==
0.00278
);
assertTrue
(
GeoUtils
.
toDecimalLatitude
(
"000010S"
)
==
-
0.00278
);
}
@Test
public
void
testLongitude
()
throws
CoordinateConversionException
{
assertTrue
(
GeoUtils
.
toDecimalLongitude
(
null
)
==
null
);
...
...
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