Commit d2fd154a authored by Eric Duminil's avatar Eric Duminil
Browse files

Allow floats too

parent 7a083c59
......@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
......@@ -17,13 +16,15 @@ import org.locationtech.jts.geom.Point;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
public class TreeKatasterData {
public class TreeKatasterData
{
public static final double TRUNK_PERCENTAGE = 0.2;
public static final double CROWN_PERCENTAGE = 1 - TRUNK_PERCENTAGE;
private List<Tree> trees;
public static TreeKatasterData parseTreeKatasterData(Path path) throws IOException {
TreeKatasterData result = new TreeKatasterData();
Map<String, Object> readParameters = new HashMap<>();
......@@ -50,7 +51,7 @@ public class TreeKatasterData {
if (treeHeightObject == null) {
continue;
}
int treeHeight = Integer.parseInt(treeHeightObject.toString());
float treeHeight = Float.parseFloat(treeHeightObject.toString());
double crownHeight = CROWN_PERCENTAGE * treeHeight;
double trunkHeight = TRUNK_PERCENTAGE * treeHeight;
tree.setCrownHeight(crownHeight);
......@@ -65,7 +66,7 @@ public class TreeKatasterData {
if (trunkCirc == null) {
continue;
}
int circInCm = Integer.parseInt(trunkCirc.toString());
float circInCm = Float.parseFloat(trunkCirc.toString());
if (circInCm == 0) {
circInCm = 89;
}
......@@ -75,7 +76,7 @@ public class TreeKatasterData {
}
return result;
}
public List<Tree> getTrees() {
if (trees == null) {
trees = new ArrayList<>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment