Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Peter Lundin
iso_spline_2
Commits
ea87ceeb
Commit
ea87ceeb
authored
Oct 08, 2017
by
peter
Browse files
Not complete solution - buggy
parent
c664829f
Changes
8
Hide whitespace changes
Inline
Side-by-side
isospline/Coordinate.java
View file @
ea87ceeb
...
...
@@ -89,6 +89,8 @@ public class Coordinate implements Cloneable{
sb
.
append
(
y
);
sb
.
append
(
"] => "
);
sb
.
append
(
value
);
sb
.
append
(
" => "
);
sb
.
append
(
direction
);
// sb.append(" Direction: ");
// if(direction!=null)
// sb.append(direction);
...
...
isospline/IsoSpline.java
View file @
ea87ceeb
...
...
@@ -52,42 +52,45 @@ public class IsoSpline {
private
Polygons
createPolygons
(
double
isoLevel
,
Color
color
){
Polygons
polygons
=
new
Polygons
();
String
direction
;
IsoSplineElement
currentIses
;
IsoSplineElements
ises
;
IsoSplineContainer
start
;
IsoSplineContainer
finish
;
IsoSplineContainer
current
;
IsoSplineContainer
start
Container
;
IsoSplineContainer
finish
Container
;
IsoSplineContainer
current
Container
;
for
(
int
r
=
0
;
r
<
iscs
.
rows
;
r
++)
for
(
int
c
=
0
;
c
<
iscs
.
cols
;
c
++){
start
=
iscs
.
getIsoSplineContainer
(
r
,
c
);
start
Container
=
iscs
.
getIsoSplineContainer
(
r
,
c
);
Polygon
polygon
=
new
Polygon
();
polygon
.
color
=
color
;
if
(
start
.
hasIsoSplineElement
()){
ises
=
new
IsoSplineElements
(
"IsoLevel: "
+
isoLevel
,
color
,
start
.
ref
);
if
(
start
Container
.
hasIsoSplineElement
()){
ises
=
new
IsoSplineElements
(
"IsoLevel: "
+
isoLevel
,
color
,
start
Container
.
ref
);
int
sortIndex
=
0
;
ises
.
add
(
start
.
getIsoSplineElement
(
sortIndex
));
currentIses
=
startContainer
.
getIsoSplineElement
(
sortIndex
);
ises
.
add
(
currentIses
);
//System.out.println("new polygon " + isoLevel);
direction
=
start
.
getPrimaryDirection
();
current
=
start
;
current
.
nextDirection
=
direction
;
//direction = start.getPrimaryDirection();
direction
=
currentIses
.
get
(
0
).
direction
;
currentContainer
=
startContainer
;
currentContainer
.
nextDirection
=
direction
;
//System.out.println("rc: > (" + current.ref.r + ", "+ current.ref.c + ") direction " + direction + " (next direction " + current.nextDirection + ")");
while
(
current
.
hasNotUsedNeighbourInDirection
()){
current
=
step
(
current
,
ises
,
sortIndex
);
while
(
current
Container
.
hasNotUsedNeighbourInDirection
()){
current
Container
=
step
(
current
Container
,
ises
,
sortIndex
);
sortIndex
++;
}
finish
=
current
;
finish
Container
=
currentContainer
;
if
(!
current
.
equals
(
start
)){
current
=
start
;
direction
=
current
.
getSecondaryD
irection
()
;
current
.
nextDirection
=
direction
;
if
(!
current
Container
.
equals
(
start
Container
)){
current
Container
=
startContainer
;
direction
=
startContainer
.
coords
.
get
(
1
).
d
irection
;
current
Container
.
nextDirection
=
direction
;
//System.out.println("rc: < (" + current.ref.r + ", "+ current.ref.c + ") direction " + direction + " (next direction " + current.nextDirection + ")");
sortIndex
=-
1
;
while
(
current
.
hasNotUsedNeighbourInDirection
()){
current
=
step
(
current
,
ises
,
sortIndex
);
while
(
current
Container
.
hasNotUsedNeighbourInDirection
()){
current
Container
=
step
(
current
Container
,
ises
,
sortIndex
);
sortIndex
--;
}
if
(!
current
.
equals
(
finish
))
if
(!
current
Container
.
equals
(
finish
Container
))
polygon
.
closed
=
true
;
}
else
...
...
isospline/IsoSplineContainer.java
View file @
ea87ceeb
/*
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
...
...
@@ -21,9 +21,10 @@ public class IsoSplineContainer {
public
final
ArrayList
<
Coordinate
>
coords
=
new
ArrayList
();
private
IsoSplineElements
ises
;
public
final
Coordinate
ref
;
private
final
ArrayList
<
String
>
directions
=
new
ArrayList
();
private
final
ArrayList
<
String
>
compass
=
new
ArrayList
();
public
String
nextDirection
=
NO_DIRECTION
;
public
int
currentIsoSplineElementIndex
=
0
;
public
IsoSplineContainer
(
IsoSplineContainers
iscs
,
Coordinate
coord0
,
Coordinate
coord1
,
Coordinate
coord2
,
Coordinate
coord3
){
this
.
iscs
=
iscs
;
coords
.
add
(
coord0
);
...
...
@@ -48,11 +49,11 @@ public class IsoSplineContainer {
public
String
getPrimaryDirection
(){
return
direction
s
.
get
(
0
)
;
return
ises
.
get
(
currentIsoSplineElementIndex
).
get
(
0
).
direction
;
}
public
String
getSecondaryDirection
(){
return
direction
s
.
get
(
1
)
;
return
ises
.
get
(
currentIsoSplineElementIndex
).
get
(
1
).
direction
;
}
public
String
getOppositeDirection
(
String
direction
){
...
...
@@ -68,10 +69,15 @@ public class IsoSplineContainer {
}
public
void
setNextDirection
(
String
direction
){
if
(
directions
.
contains
(
direction
))
nextDirection
=
directions
.
get
(
1
-
directions
.
indexOf
(
direction
));
else
nextDirection
=
NO_DIRECTION
;
for
(
int
i
=
0
;
i
<
ises
.
size
();
i
++)
for
(
int
j
=
0
;
j
<
ises
.
size
();
j
++)
if
(
ises
.
get
(
i
).
get
(
j
).
direction
.
equals
(
direction
)){
nextDirection
=
ises
.
get
(
i
).
get
(
1
-
j
).
direction
;
currentIsoSplineElementIndex
=
i
;
break
;
}
nextDirection
=
NO_DIRECTION
;
}
public
boolean
hasNotUsedNeighbourInDirection
(){
...
...
@@ -117,7 +123,6 @@ public class IsoSplineContainer {
double
lat
=
range
*
(
coord2
.
lat
-
coord1
.
lat
)
+
coord1
.
lat
;
double
lon
=
range
*
(
coord2
.
lon
-
coord1
.
lon
)
+
coord1
.
lon
;
splineCoords
.
add
(
new
Coordinate
(
lon
,
lat
,
coord1
.
r
,
coord1
.
c
,
isoLevel
,
compass
.
get
(
i
)));
directions
.
add
(
compass
.
get
(
i
));
}
}
ises
=
new
IsoSplineElements
(
ref
);
...
...
@@ -154,9 +159,9 @@ public class IsoSplineContainer {
public
IsoSplineElement
getIsoSplineElement
(
int
sortIndex
){
i
nt
i
=
0
;
// TODO
IsoSplineElement
ise
=
ises
.
get
(
i
);
ises
.
remove
(
i
)
;
IsoSplineEleme
nt
i
se
=
ises
.
get
(
currentIsoSplineElementIndex
);
ises
.
remove
(
currentIsoSplineElementIndex
);
currentIsoSplineElementIndex
=
0
;
ise
.
sortIndex
=
sortIndex
;
return
ise
;
}
...
...
@@ -174,21 +179,21 @@ public class IsoSplineContainer {
double
min
=
Math
.
min
(
min02
,
min13
);
double
max
=
Math
.
max
(
max02
,
max13
);
// Undefined level
if
(
min02
>=
max13
)
if
(
isoLevel
>=
max13
&&
isoLevel
<=
min02
)
return
false
;
// Undefined level
if
(
min13
>=
max02
)
if
(
isoLevel
>=
max02
&&
isoLevel
<=
min13
)
return
false
;
//
// Undefined level
//
if(min02 >= max13)
//
if(isoLevel >= max13 && isoLevel <= min02)
//
return false;
//
// Undefined level
//
if(min13 >= max02)
//
if(isoLevel >= max02 && isoLevel <= min13)
//
return false;
// Iso out of range
if
(
isoLevel
<=
min
||
max
<=
isoLevel
)
return
false
;
if
(
Math
.
abs
(
min
-
max
)
<
Coordinate
.
MAX_DIFF
)
return
false
;
//
if(Math.abs(min - max) < Coordinate.MAX_DIFF)
//
return false;
return
true
;
}
...
...
isospline/Main.java
View file @
ea87ceeb
...
...
@@ -20,7 +20,7 @@ import org.json.JSONException;
*/
public
class
Main
{
public
static
final
int
ISO_LEVELS
=
3
;
public
static
final
boolean
test
=
fals
e
;
public
static
final
boolean
test
=
tru
e
;
public
static
int
minPolygonSize
=
1
;
public
static
boolean
filtering
=
true
;
public
static
boolean
original
=
false
;
...
...
isospline/analy
s
e/IsoErrorElement.java
→
isospline/analy
z
e/IsoErrorElement.java
View file @
ea87ceeb
...
...
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
isospline.analy
s
e
;
package
isospline.analy
z
e
;
/**
*
...
...
isospline/analy
s
e/IsoErrorlist.java
→
isospline/analy
z
e/IsoErrorlist.java
View file @
ea87ceeb
...
...
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
isospline.analy
s
e
;
package
isospline.analy
z
e
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
isospline/analyze/IsoSplineAnalyze.java
View file @
ea87ceeb
...
...
@@ -26,7 +26,7 @@ public class IsoSplineAnalyze {
matrix
.
add
(
new
Coordinate
(
1.0
,
0.0
,
1
,
0
,
3.0
,
null
));
matrix
.
add
(
new
Coordinate
(
1.0
,
1.0
,
1
,
1
,
2.0
,
null
));
double
iso
=
3
.0001
;
double
iso
=
2
.0001
;
iscs
=
new
IsoSplineContainers
(
1
,
1
);
iscs
.
createIsoSplineContainers
(
matrix
);
...
...
isospline/io/JSONMatrix.java
View file @
ea87ceeb
...
...
@@ -7,6 +7,7 @@ package isospline.io;
import
isospline.Coordinate
;
import
isospline.Matrix
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
...
...
@@ -27,6 +28,8 @@ public class JSONMatrix{
private
static
int
rows
=
0
;
private
static
int
cols
=
0
;
public
static
JSONObject
parseJSONFile
(
String
filename
)
throws
JSONException
,
IOException
{
File
file
=
new
File
(
filename
);
System
.
out
.
println
(
"fileName "
+
file
.
getAbsolutePath
());
String
content
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
filename
)));
return
new
JSONObject
(
content
);
}
...
...
@@ -38,8 +41,10 @@ public class JSONMatrix{
GRID_COEFF
=
1
;
rows
=
5
;
cols
=
4
;
gridfilename
=
"D:\\git\\GribVisualizer\\src\\isospline\\data\\testmultipoint.json"
;
datafilename
=
"D:\\git\\GribVisualizer\\src\\isospline\\data\\test_data.json"
;
// gridfilename = "D:\\git\\GribVisualizer\\src\\isospline\\data\\testmultipoint.json";
// datafilename = "D:\\git\\GribVisualizer\\src\\isospline\\data\\test_data.json";
gridfilename
=
"src/isospline/data/testmultipoint.json"
;
datafilename
=
"src/isospline/data/test_data.json"
;
}
else
{
GRID_COEFF
=
50
;
...
...
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