From d74ab63445ea276010bdc147475ef1440e3e827b Mon Sep 17 00:00:00 2001 From: filip Date: Fri, 3 Jul 2015 11:49:17 +0200 Subject: [PATCH] polygons are mapped to area now --- README.textile | 42 +++--- src/app/Spread2ConsoleApp.java | 2 +- src/exceptions/MissingAttributeException.java | 2 +- src/parsers/DiscretePolygonsParser.java | 3 + ...rser.java => DiscreteTreeLinesParser.java} | 130 ++++++++++-------- src/parsers/DiscreteTreeParser.java | 5 +- src/renderers/kml/KmlRenderer.java | 20 ++- .../parsing/DiscreteTreeSettings.java | 2 +- src/settings/parsing/TimeSlicerSettings.java | 2 +- .../rendering/KmlRendererSettings.java | 6 +- 10 files changed, 126 insertions(+), 88 deletions(-) rename src/parsers/{DiscreteLinesParser.java => DiscreteTreeLinesParser.java} (60%) diff --git a/README.textile b/README.textile index 272254f..bebb367 100644 --- a/README.textile +++ b/README.textile @@ -93,6 +93,9 @@ h3. PARSING * cut into 10 discrete time intervals -parse -locations /home/filip/Dropbox/JavaProjects/Spread2/data/discrete/H5N1/locationCoordinates_H5N1 -tree /home/filip/Dropbox/JavaProjects/Spread2/data/discrete/H5N1/H5N1_HA_discrete_MCC.tre -locationTrait states -intervals 10 -mrsd 2011-01-01 -output test_discrete.json +* mrsd in decimal format +-parse -locations /home/filip/Dropbox/JavaProjects/Spread2/data/discrete/H5N1/locationCoordinates_H5N1 -tree /home/filip/Dropbox/JavaProjects/Spread2/data/discrete/H5N1/H5N1_HA_discrete_MCC.tre -locationTrait states -intervals 10 -mrsd 2011.653 -output test_discrete.json + h3. RENDERING * use all default settings @@ -118,47 +121,47 @@ h4. POLYGONS * map alpha channel for polygons, this option overwrites all previous settings, including those in color sheet: -render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -output test.kml -* override default polygon radius (in KM) settings: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradius 200 -output test.kml +* override default polygon area (in KM^2) settings: +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonarea 200000 -output test.kml -* map polygon radius to count attribute values --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping count -output test.kml +* map polygon area to count attribute values +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping count -output test.kml -* map polygon radius to location attribute values --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -output test.kml +* map polygon area to location attribute values +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -output test.kml h4. LINES * override default line color settings: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolor 250 0 0 -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolor 250 0 0 -output test.kml * map line colors to distance attribute values, use built-in color schemes --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping distance -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping distance -output test.kml * map line colors to locations, use supplied color sheet (RGB or RGBA values) --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -output test.kml * specify alpha channel for lines, this option overwrites all previous settings, including those in color sheet: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 150 -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 150 -output test.kml * map alpha channel for lines to duration attribute values, this option overwrites all previous settings, including those in color sheet. Duration attribute applies to a whole branch and colors are not interpolated to reflect that: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping duration -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping duration -output test.kml * map alpha channel for lines to locations, this option overwrites all previous settings, including those in color sheet. For lines which change location line alpha will be interpolated to reflect that: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping location -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping location -output test.kml * override default line width settings: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping location -linewidth 3 -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealphamapping location -linewidth 3 -output test.kml * map lines width to duration attribute values. Width can only be mapped to attributes which apply to a whole branch. --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -output test.kml * override default line altitude settings: --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -linealtitude 100000 -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -linealtitude 100000 -output test.kml * map lines altitude to distance attribute values. Altitude can only be mapped to attributes which apply to a whole branch. --render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonradiusmapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -linealtitudemapping distance -output test.kml +-render kml -json /home/filip/Dropbox/JavaProjects/Spread2/test_discrete.json -polygoncolormapping location -polygoncolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -polygonalphamapping count -polygonareamapping location -linecolormapping location -linecolors /home/filip/Dropbox/JavaProjects/Spread2/data/H5N1colors -linealpha 255 -linewidthmapping duration -linealtitudemapping distance -output test.kml h3. BAYES FACTORS @@ -197,6 +200,9 @@ h3. PARSING * parse other numerical traits for imputing -parse -tree /home/filip/Dropbox/JavaProjects/Spread2/data/continuous/locationHost/HA_loc_host_mcc.tre -trees /home/filip/Dropbox/JavaProjects/Spread2/data/continuous/locationHost/HA_loc_host_small.trees -traits location,trait2 -hpd 0.8 -intervals 20 -burnin 5 -mrsd 2011-01-01 -output test_slice.json +* mrsd in decimal format +-parse -tree /home/filip/Dropbox/JavaProjects/Spread2/data/continuous/WNV/WNV_relaxed_geo_gamma_MCC.tre -trees /home/filip/Dropbox/JavaProjects/Spread2/data/continuous/WNV/WNV_relaxed_geo_gamma.trees -traits location -hpd 0.8 -intervals 15 -burnin 5 -mrsd 2011.653 -output test_slice.json + h3. RENDERING * use all default settings @@ -230,13 +236,13 @@ h1. TODO * Date-time calculations - time scale multiplier - - If no date specified everything goes to 0 * Renderers - D3 renderer - GeoJSON renderer - - KML renderers + - KML renderer - control arc curvature [0 - 1] * Non-geographic locations (e.g. antigenic locations) +* parsing BEAST2 and MrBayes output * Restrict visual summaries or rate statistics to a particular set of nodes, like a clade or a trunk/backbone * Display warning if one or more of the discrete states are not found. * Uncaught exception handler (for bug reports). diff --git a/src/app/Spread2ConsoleApp.java b/src/app/Spread2ConsoleApp.java index b8eec7d..4c1bc0a 100644 --- a/src/app/Spread2ConsoleApp.java +++ b/src/app/Spread2ConsoleApp.java @@ -97,7 +97,7 @@ public class Spread2ConsoleApp { private static final String POLYGON_ALPHA = "polygonalpha"; private static final String POLYGON_AREA = "polygonarea"; - private static final String POLYGON_AREA_MAPPING = "polygonradiusmapping"; + private static final String POLYGON_AREA_MAPPING = "polygonareamapping"; private static final String LINE_COLOR_MAPPING = "linecolormapping"; private static final String LINE_COLORS = "linecolors"; diff --git a/src/exceptions/MissingAttributeException.java b/src/exceptions/MissingAttributeException.java index a133514..4096249 100644 --- a/src/exceptions/MissingAttributeException.java +++ b/src/exceptions/MissingAttributeException.java @@ -18,7 +18,7 @@ public MissingAttributeException(String attributeName, String name) { @Override public String getMessage() { - String message = "Attribute " + attributeName + " missing from " + name +" attributes"; + String message = "Attribute " + attributeName + " missing from " + name + " attributes"; return message; } diff --git a/src/parsers/DiscretePolygonsParser.java b/src/parsers/DiscretePolygonsParser.java index 6aced33..66b5597 100644 --- a/src/parsers/DiscretePolygonsParser.java +++ b/src/parsers/DiscretePolygonsParser.java @@ -142,6 +142,9 @@ public LinkedList parseDiscretePolygons() throws LocationNotFoundExcep }// END: traits loop }// END: null check + Trait locationTrait = new Trait(location.getId()); + attributes.put(LOCATION, locationTrait); + Trait countTrait = new Trait(locationCount); attributes.put(COUNT, countTrait); diff --git a/src/parsers/DiscreteLinesParser.java b/src/parsers/DiscreteTreeLinesParser.java similarity index 60% rename from src/parsers/DiscreteLinesParser.java rename to src/parsers/DiscreteTreeLinesParser.java index 45f5e30..a4a8c61 100644 --- a/src/parsers/DiscreteLinesParser.java +++ b/src/parsers/DiscreteTreeLinesParser.java @@ -17,118 +17,130 @@ import exceptions.AnalysisException; import exceptions.LocationNotFoundException; -public class DiscreteLinesParser { +public class DiscreteTreeLinesParser { - String locationTrait; - List locationsList; - RootedTree rootedTree; + private String locationTrait; + private List locationsList; + private RootedTree rootedTree; private String[] traits; + private String mrsd; - public DiscreteLinesParser(RootedTree rootedTree, String locationTrait, List locationsList, String traits[]) { - + public DiscreteTreeLinesParser(RootedTree rootedTree, // + String locationTrait, // + List locationsList, // + String traits[], // + String mrsd // + ) { + this.locationTrait = locationTrait; this.locationsList = locationsList; this.rootedTree = rootedTree; this.traits = traits; + this.mrsd = mrsd; - }//END: Constructor - - public LinkedList parseLines() throws IOException, ImportException, LocationNotFoundException, AnalysisException { - + }// END: Constructor + + public LinkedList parseLines() throws IOException, ImportException, + LocationNotFoundException, AnalysisException { + LinkedList linesList = new LinkedList(); - + + TimeParser timeParser = new TimeParser(mrsd); + timeParser.parseTime(); + Location dummy; for (Node node : rootedTree.getNodes()) { if (!rootedTree.isRoot(node)) { Node parentNode = rootedTree.getParent(node); - - String parentState = (String) Utils.getObjectNodeAttribute(parentNode, locationTrait); - if(parentState.contains("+")) { + + String parentState = (String) Utils.getObjectNodeAttribute( + parentNode, locationTrait); + if (parentState.contains("+")) { String message = "Found tied state " + parentState + "."; parentState = Utils.breakTiesRandomly(parentState); message += (" randomly choosing " + parentState + "."); System.out.println(message); - }//END: tie check - - String nodeState = (String) Utils.getObjectNodeAttribute(node, locationTrait); - if(nodeState.contains("+")) { + }// END: tie check + + String nodeState = (String) Utils.getObjectNodeAttribute(node, + locationTrait); + if (nodeState.contains("+")) { String message = "Found tied state " + nodeState + "."; nodeState = Utils.breakTiesRandomly(nodeState); message += (" Randomly choosing " + nodeState + "."); System.out.println(message); - }//END: tie check - - dummy = new Location(parentState, "", new Coordinate(0.0, 0.0), null); + }// END: tie check + + dummy = new Location(parentState, "", new Coordinate(0.0, 0.0), + null); int parentLocationIndex = Integer.MAX_VALUE; - if(locationsList.contains(dummy)) { - parentLocationIndex = locationsList.indexOf(dummy); + if (locationsList.contains(dummy)) { + parentLocationIndex = locationsList.indexOf(dummy); } else { throw new LocationNotFoundException(dummy); } - - dummy = new Location(nodeState, "", new Coordinate(0.0, 0.0), null); + + dummy = new Location(nodeState, "", new Coordinate(0.0, 0.0), + null); int nodeLocationIndex = Integer.MAX_VALUE; - if(locationsList.contains(dummy)) { - nodeLocationIndex = locationsList.indexOf(dummy); + if (locationsList.contains(dummy)) { + nodeLocationIndex = locationsList.indexOf(dummy); } else { throw new LocationNotFoundException(dummy); } - - Location parentLocation = locationsList.get(parentLocationIndex); + + Location parentLocation = locationsList + .get(parentLocationIndex); Location nodeLocation = locationsList.get(nodeLocationIndex); if (!(parentLocation.equals(nodeLocation))) { - Double parentHeight = Utils.getNodeHeight(rootedTree, parentNode); + Double parentHeight = Utils.getNodeHeight(rootedTree, + parentNode); + String startTime = timeParser.getNodeDate(parentHeight); + Double nodeHeight = Utils.getNodeHeight(rootedTree, node); - + String endTime = timeParser.getNodeDate(nodeHeight); + Map attributes = new LinkedHashMap(); - + if (traits != null) { for (String traitName : traits) { -// Object parentTraitObject = Utils -// .getObjectNodeAttribute(parentNode, -// traitName); -// Trait parentTrait = new Trait(parentTraitObject, -// parentHeight); - - Trait parentTrait = Utils.getNodeTrait(parentNode, traitName); - + Trait parentTrait = Utils.getNodeTrait(parentNode, + traitName); attributes .put(Utils.START + traitName, parentTrait); -// Object nodeTraitObject = Utils -// .getObjectNodeAttribute(node, traitName); -// Trait nodeTrait = new Trait(nodeTraitObject, -// nodeHeight); - - Trait nodeTrait = Utils.getNodeTrait(node, traitName); - + Trait nodeTrait = Utils.getNodeTrait(node, + traitName); attributes.put(Utils.END + traitName, nodeTrait); }// END: traits loop }// END: null check - - // branch attribute traits - + + // branch attribute traits + double branchDuration = parentHeight - nodeHeight; Trait branchDurationTrait = new Trait(branchDuration); attributes.put(Utils.DURATION, branchDurationTrait); - - double distance = Utils.rhumbDistance(parentLocation.getCoordinate(), nodeLocation.getCoordinate()); + + double distance = Utils.rhumbDistance( + parentLocation.getCoordinate(), + nodeLocation.getCoordinate()); Trait distanceTrait = new Trait(distance); attributes.put(Utils.DISTANCE, distanceTrait); - - Line line = new Line(parentLocation, nodeLocation, "", "", attributes); + + Line line = new Line(parentLocation, nodeLocation, + startTime, endTime, attributes); linesList.add(line); }// END: branch changes state check - + }// END: root check }// END: node loop - + return linesList; - }//END: parseLines - -}//END: class + }// END: parseLines + +}// END: class diff --git a/src/parsers/DiscreteTreeParser.java b/src/parsers/DiscreteTreeParser.java index cc2c7bf..83171a1 100644 --- a/src/parsers/DiscreteTreeParser.java +++ b/src/parsers/DiscreteTreeParser.java @@ -49,10 +49,11 @@ public SpreadData parse() throws IOException, ImportException, System.out.println("Parsing lines"); - DiscreteLinesParser linesParser = new DiscreteLinesParser(rootedTree, // + DiscreteTreeLinesParser linesParser = new DiscreteTreeLinesParser(rootedTree, // settings.locationTrait, // locationsList, // - settings.traits // + settings.traits, // + settings.mrsd // ); linesList = linesParser.parseLines(); diff --git a/src/renderers/kml/KmlRenderer.java b/src/renderers/kml/KmlRenderer.java index a71fee5..e4f3c11 100644 --- a/src/renderers/kml/KmlRenderer.java +++ b/src/renderers/kml/KmlRenderer.java @@ -350,6 +350,10 @@ private Feature generateLine( if (this.settings.lineColorMapping != null) { // map double[] minmax = minmaxMap.get(settings.lineColorMapping); + if(minmax == null) { + throw new MissingAttributeException(settings.polygonColorMapping, MissingAttributeException.POLYGON); + } + double minValue = minmax[MIN_INDEX]; double maxValue = minmax[MAX_INDEX]; @@ -359,6 +363,7 @@ private Feature generateLine( startTrait = line.getAttributes().get(Utils.START + settings.lineColorMapping); } + // Discrete lines have start and end locations if (startTrait == null) { if (line.connectsLocations()) { startTrait = new Trait(line.getStartLocation().getId()); @@ -404,6 +409,7 @@ private Feature generateLine( endTrait = line.getAttributes().get(Utils.START + settings.lineColorMapping); } + // Discrete lines have start and end locations if (endTrait == null) { if (line.connectsLocations()) { endTrait = new Trait(line.getEndLocation().getId()); @@ -645,8 +651,6 @@ private Feature generateLine( LinkedList coords = getIntermediateCoords(startCoordinate, endCoordinate, sliceCount); - //TODO: move date-time calculations to TimeParser [!] - String startTime = line.getStartTime(); DateTime startDate = new DateTime(startTime); @@ -763,6 +767,8 @@ public Feature generatePolygons(List polygons) throws IOException, Miss Map attributes = polygon.getAttributes(); +// Utils.printMap(attributes); + Iterator it = attributes.entrySet().iterator(); while (it.hasNext()) { @@ -792,6 +798,8 @@ public Feature generatePolygons(List polygons) throws IOException, Miss String traitName = (String) pairs.getKey(); +// System.out.println(traitName); + if(!minmaxMap.containsKey(traitName)) { double[] minmax = new double[2]; @@ -840,6 +848,10 @@ public Feature generatePolygons(List polygons) throws IOException, Miss if (this.settings.polygonColorMapping != null) {// map double[] minmax = minmaxMap.get(settings.polygonColorMapping); + if(minmax == null) { + throw new MissingAttributeException(settings.polygonColorMapping, MissingAttributeException.POLYGON); + } + double minValue = minmax[MIN_INDEX]; double maxValue = minmax[MAX_INDEX]; @@ -1007,6 +1019,8 @@ private Feature generatePolygon(Polygon polygon, // } // END: settings check +// System.out.println(centroid.getId() + ": " + area); + points.addAll(generateCircle(centroid, area, numPoints)); } else { @@ -1051,6 +1065,8 @@ private List generateCircle(Location centroid, double area, int numPoint double radius = Math.sqrt(area/Math.PI); +// System.out.println(centroid.getId() + ": " + radius); + Double latitude = centroid.getCoordinate().getLatitude(); Double longitude = centroid.getCoordinate().getLongitude(); diff --git a/src/settings/parsing/DiscreteTreeSettings.java b/src/settings/parsing/DiscreteTreeSettings.java index 8b560bf..b7af577 100644 --- a/src/settings/parsing/DiscreteTreeSettings.java +++ b/src/settings/parsing/DiscreteTreeSettings.java @@ -25,6 +25,6 @@ public class DiscreteTreeSettings { public String output = "output.json"; // moste recent sampling date string yyy-MM-dd - public String mrsd = null; + public String mrsd = "0-0-0"; }//END: class diff --git a/src/settings/parsing/TimeSlicerSettings.java b/src/settings/parsing/TimeSlicerSettings.java index 80a1c13..fa9792d 100644 --- a/src/settings/parsing/TimeSlicerSettings.java +++ b/src/settings/parsing/TimeSlicerSettings.java @@ -38,6 +38,6 @@ public class TimeSlicerSettings { public String output = "output.json"; // most recent sampling date yyy/mm/dd - public String mrsd = null; + public String mrsd = "0-0-0"; }//END: class diff --git a/src/settings/rendering/KmlRendererSettings.java b/src/settings/rendering/KmlRendererSettings.java index e99c1a7..91924c7 100644 --- a/src/settings/rendering/KmlRendererSettings.java +++ b/src/settings/rendering/KmlRendererSettings.java @@ -108,13 +108,13 @@ public class KmlRendererSettings { // For continuous attributes public String polygonAreaMapping= null; - public Double minPolygonArea = 100.0; public Double maxPolygonRadius = 1000.0; + public Double minPolygonArea = 20000.0; public Double maxPolygonRadius = 200000.0; // For discrete attributes - //TODO: file with radius, make a joint CSS style sheet for all these settings + //TODO: make a joint CSS [?] style sheet for all these settings // Fixed - public Double polygonArea = 100.0; + public Double polygonArea = 20000.0;