1 |
1 |
// $Id$
|
2 |
2 |
/**
|
3 |
3 |
* Copyright (C) 2007 EDIT
|
4 |
|
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy
|
5 |
5 |
* http://www.e-taxonomy.eu
|
6 |
|
*
|
|
6 |
*
|
7 |
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8 |
8 |
* See LICENSE.TXT at the top of this package for the full license terms.
|
9 |
9 |
*/
|
... | ... | |
56 |
56 |
private static final Logger logger = Logger.getLogger(EditGeoServiceUtilities.class);
|
57 |
57 |
|
58 |
58 |
private static PresenceAbsenceTermBase<?> defaultStatus = PresenceTerm.PRESENT();
|
59 |
|
|
|
59 |
|
60 |
60 |
private static IDefinedTermDao termDao;
|
61 |
|
|
|
61 |
|
62 |
62 |
/**
|
63 |
63 |
* @param termDao
|
64 |
64 |
*/
|
65 |
65 |
public static void setTermDao(IDefinedTermDao termDao) {
|
66 |
66 |
EditGeoServiceUtilities.termDao= termDao;
|
67 |
67 |
}
|
68 |
|
|
|
68 |
|
69 |
69 |
private static HashMap<Class<? extends SpecimenOrObservationBase>, Color> defaultSpecimenOrObservationTypeColors = null;
|
70 |
70 |
|
71 |
71 |
private static HashMap<Class<? extends SpecimenOrObservationBase>, Color> getDefaultSpecimenOrObservationTypeColors() {
|
... | ... | |
75 |
75 |
defaultSpecimenOrObservationTypeColors.put(DerivedUnit.class, Color.RED);
|
76 |
76 |
defaultSpecimenOrObservationTypeColors.put(LivingBeing.class, Color.GREEN);
|
77 |
77 |
defaultSpecimenOrObservationTypeColors.put(Observation.class, Color.ORANGE);
|
78 |
|
defaultSpecimenOrObservationTypeColors.put(Specimen.class, Color.GRAY);
|
|
78 |
defaultSpecimenOrObservationTypeColors.put(Specimen.class, Color.GRAY);
|
79 |
79 |
}
|
80 |
80 |
return defaultSpecimenOrObservationTypeColors;
|
81 |
81 |
}
|
... | ... | |
93 |
93 |
defaultPresenceAbsenceTermBaseColors.put(PresenceTerm.INTRODUCED(), Color.decode("0xff7f00"));
|
94 |
94 |
defaultPresenceAbsenceTermBaseColors.put(PresenceTerm.INTRODUCED_ADVENTITIOUS(), Color.decode("0xffff33"));
|
95 |
95 |
defaultPresenceAbsenceTermBaseColors.put(PresenceTerm.INTRODUCED_CULTIVATED(), Color.decode("0xa65628"));
|
96 |
|
defaultPresenceAbsenceTermBaseColors.put(PresenceTerm.INTRODUCED_NATURALIZED(), Color.decode("0xf781bf"));
|
97 |
|
|
|
96 |
defaultPresenceAbsenceTermBaseColors.put(PresenceTerm.INTRODUCED_NATURALIZED(), Color.decode("0xf781bf"));
|
|
97 |
|
98 |
98 |
/*
|
99 |
99 |
* and now something very hacky ...
|
100 |
100 |
* ONLY-A-TEST is set by the Test class EditGeoServiceTest
|
101 |
|
*
|
|
101 |
*
|
102 |
102 |
* TODO remove according line from
|
103 |
103 |
* EditGeoServiceTest.setUp() when the hardcoded colors for flora of
|
104 |
104 |
* cyprus are no further needed !!
|
105 |
105 |
*/
|
106 |
|
String onlyTest = System.getProperty("ONLY-A-TEST"); //
|
|
106 |
String onlyTest = System.getProperty("ONLY-A-TEST"); //
|
107 |
107 |
if(onlyTest != null && onlyTest.equals("TRUE")){
|
108 |
108 |
return defaultPresenceAbsenceTermBaseColors;
|
109 |
109 |
}
|
110 |
110 |
//special colors for flora of cyprus !!! see HACK above !!!
|
111 |
111 |
UUID indigenousUuid = UUID.fromString("b325859b-504b-45e0-9ef0-d5c1602fcc0f");
|
112 |
112 |
UUID indigenousQUuid = UUID.fromString("17bc601f-53eb-4997-a4bc-c03ce5bfd1d3");
|
113 |
|
|
|
113 |
|
114 |
114 |
UUID cultivatedQUuid = UUID.fromString("4f31bfc8-3058-4d83-aea5-3a1fe9773f9f");
|
115 |
|
|
|
115 |
|
116 |
116 |
UUID casualUuid = UUID.fromString("5e81353c-38a3-4ca6-b979-0d9abc93b877");
|
117 |
117 |
UUID casualQUuid = UUID.fromString("73f75493-1185-4a3e-af1e-9a1f2e8dadb7");
|
118 |
|
|
|
118 |
|
119 |
119 |
UUID naturalizedNonInvasiveUuid = UUID.fromString("1b025e8b-901a-42e8-9739-119b410c6f03");
|
120 |
120 |
UUID naturalizedNonInvasiveQUuid = UUID.fromString("11f56e2f-c16c-4b3d-a870-bb5d3b20e624");
|
121 |
|
|
|
121 |
|
122 |
122 |
UUID naturalizedInvasiveUuid = UUID.fromString("faf2d271-868a-4bf7-b0b8-a1c5ab309de2");
|
123 |
123 |
UUID naturalizedInvasiveQUuid = UUID.fromString("ac429d5f-e8ad-49ae-a41c-e4779b58b96a");
|
124 |
|
|
|
124 |
|
125 |
125 |
UUID questionablelUuid = UUID.fromString("4b48f675-a6cf-49f3-a5ba-77e2c2979eb3");
|
126 |
126 |
UUID questionableQUuid = UUID.fromString("914e7393-1314-4632-bc45-5eff3dc1e424");
|
127 |
|
|
|
127 |
|
128 |
128 |
UUID reportedInErrorUuid = UUID.fromString("38604788-cf05-4607-b155-86db456f7680");
|
129 |
|
|
|
129 |
|
130 |
130 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(indigenousUuid), Color.decode("0x339966"));
|
131 |
131 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(indigenousQUuid), Color.decode("0x339966"));
|
132 |
|
|
|
132 |
|
133 |
133 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(cultivatedQUuid), Color.decode("0xbdb76b"));
|
134 |
|
|
|
134 |
|
135 |
135 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(casualUuid), Color.decode("0xffff00"));
|
136 |
136 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(casualQUuid), Color.decode("0xffff00"));
|
137 |
|
|
|
137 |
|
138 |
138 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(naturalizedNonInvasiveUuid), Color.decode("0xff9900"));
|
139 |
139 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(naturalizedNonInvasiveQUuid), Color.decode("0xff9900"));
|
140 |
|
|
|
140 |
|
141 |
141 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(naturalizedInvasiveUuid), Color.decode("0xff0000"));
|
142 |
142 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(naturalizedInvasiveQUuid), Color.decode("0xff0000"));
|
143 |
|
|
|
143 |
|
144 |
144 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(questionablelUuid), Color.decode("0x00ccff"));
|
145 |
145 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(questionableQUuid), Color.decode("0x00ccff"));
|
146 |
|
|
|
146 |
|
147 |
147 |
defaultPresenceAbsenceTermBaseColors.put((PresenceAbsenceTermBase<?>) termDao.load(reportedInErrorUuid), Color.decode("0xcccccc"));
|
148 |
|
|
|
148 |
|
149 |
149 |
}
|
150 |
150 |
return defaultPresenceAbsenceTermBaseColors;
|
151 |
151 |
}
|
... | ... | |
157 |
157 |
static final String ID_FROM_VALUES_SEPARATOR = ":";
|
158 |
158 |
static final String VALUE_LIST_ENTRY_SEPARATOR = "|";
|
159 |
159 |
static final String VALUE_SUPER_LIST_ENTRY_SEPARATOR = "||";
|
160 |
|
|
|
160 |
|
161 |
161 |
|
162 |
162 |
|
163 |
163 |
//preliminary implementation for TDWG areas
|
164 |
164 |
/**
|
165 |
165 |
* Returns the parameter String for the EDIT geo webservice to create a
|
166 |
166 |
* dsitribution map.
|
167 |
|
*
|
|
167 |
*
|
168 |
168 |
* @param distributions
|
169 |
169 |
* A set of distributions that should be shown on the map
|
170 |
170 |
* @param presenceAbsenceTermColors
|
... | ... | |
180 |
180 |
* @param bbox
|
181 |
181 |
* The maps bounding box (e.g. "-180,-90,180,90" for the whole
|
182 |
182 |
* world)
|
|
183 |
* @param projectToLayer
|
|
184 |
* name of a layer which is representing a specific
|
|
185 |
* {@link NamedAreaLevel} Supply this parameter if you to project
|
|
186 |
* all other distribution area levels to this layer.
|
183 |
187 |
* @param layer
|
184 |
188 |
* The layer that is responsible for background borders and
|
185 |
189 |
* colors. Use the name for the layer. If null 'earth' is taken
|
... | ... | |
189 |
193 |
*/
|
190 |
194 |
@Transient
|
191 |
195 |
public static String getDistributionServiceRequestParameterString(
|
192 |
|
Set<Distribution> distributions,
|
193 |
|
Map<PresenceAbsenceTermBase<?>,Color> presenceAbsenceTermColors,
|
194 |
|
int width,
|
195 |
|
int height,
|
196 |
|
String bbox,
|
197 |
|
String backLayer,
|
|
196 |
Set<Distribution> distributions,
|
|
197 |
Map<PresenceAbsenceTermBase<?>,Color> presenceAbsenceTermColors,
|
|
198 |
int width,
|
|
199 |
int height,
|
|
200 |
String bbox,
|
|
201 |
String baseLayerName,
|
|
202 |
String projectToLayer,
|
198 |
203 |
List<Language> languages){
|
199 |
|
|
|
204 |
|
200 |
205 |
|
201 |
206 |
/**
|
202 |
207 |
* generateMultipleAreaDataParameters switches between the two possible styles:
|
... | ... | |
209 |
214 |
List<String> areaStyles = new ArrayList<String>();
|
210 |
215 |
List<String> legendLabels = new ArrayList<String>();
|
211 |
216 |
|
212 |
|
|
|
217 |
|
213 |
218 |
String borderWidth = "0.1";
|
214 |
219 |
String borderColorRgb = "";
|
215 |
220 |
String borderDashingPattern = "";
|
216 |
|
|
217 |
|
|
|
221 |
|
|
222 |
|
218 |
223 |
if(distributions == null || distributions.size() == 0){
|
219 |
224 |
return "";
|
220 |
225 |
}
|
221 |
|
Map<String, Map<Integer, Set<Distribution>>> layerMap = new HashMap<String, Map<Integer, Set<Distribution>>>();
|
|
226 |
Map<String, Map<Integer, Set<Distribution>>> layerMap = new HashMap<String, Map<Integer, Set<Distribution>>>();
|
222 |
227 |
List<PresenceAbsenceTermBase<?>> statusList = new ArrayList<PresenceAbsenceTermBase<?>>();
|
223 |
228 |
groupStylesAndLayers(distributions, layerMap, statusList);
|
224 |
|
|
|
229 |
|
225 |
230 |
presenceAbsenceTermColors = mergeMaps(getDefaultPresenceAbsenceTermBaseColors(), presenceAbsenceTermColors);
|
226 |
231 |
|
227 |
232 |
Map<String, String> parameters = new HashMap<String, String>();
|
228 |
|
|
|
233 |
|
229 |
234 |
//bbox
|
230 |
235 |
if (bbox != null){
|
231 |
236 |
parameters.put("bbox", bbox);
|
... | ... | |
236 |
241 |
parameters.put("ms", ms);
|
237 |
242 |
}
|
238 |
243 |
//layer
|
239 |
|
if (StringUtils.isBlank(backLayer)){
|
240 |
|
backLayer = "earth";
|
|
244 |
if (StringUtils.isBlank(baseLayerName)){
|
|
245 |
baseLayerName = "earth";
|
241 |
246 |
}
|
242 |
|
parameters.put("l", backLayer);
|
243 |
|
|
|
247 |
parameters.put("l", baseLayerName);
|
|
248 |
|
244 |
249 |
//style
|
245 |
250 |
int i = 0;
|
246 |
251 |
for (PresenceAbsenceTermBase<?> status: statusList){
|
247 |
|
|
|
252 |
|
248 |
253 |
char styleId = getStyleAbbrev(i);
|
249 |
|
|
|
254 |
|
250 |
255 |
//getting the area title
|
251 |
256 |
if (languages == null){
|
252 |
257 |
languages = new ArrayList<Language>();
|
... | ... | |
259 |
264 |
//statusLabel.replace('introduced: ', '');
|
260 |
265 |
statusLabel = statusLabel.replace("introduced: ", "introduced, ");
|
261 |
266 |
statusLabel = statusLabel.replace("native: ", "native, ");
|
262 |
|
|
|
267 |
|
263 |
268 |
//getting the area color
|
264 |
269 |
Color statusColor = presenceAbsenceTermColors.get(status);
|
265 |
270 |
String fillColorRgb;
|
... | ... | |
272 |
277 |
fillColorRgb = defaultStatus.getDefaultColor();
|
273 |
278 |
}
|
274 |
279 |
}
|
275 |
|
String styleValues = StringUtils.join(new String[]{fillColorRgb, borderColorRgb, borderWidth, borderDashingPattern}, ',');
|
|
280 |
String styleValues = StringUtils.join(new String[]{fillColorRgb, borderColorRgb, borderWidth, borderDashingPattern}, ',');
|
276 |
281 |
|
277 |
282 |
areaStyles.add(styleId + ID_FROM_VALUES_SEPARATOR + styleValues);
|
278 |
283 |
legendLabels.add(styleId + ID_FROM_VALUES_SEPARATOR + encode(statusLabel));
|
279 |
|
i++;
|
|
284 |
i++;
|
280 |
285 |
}
|
281 |
|
|
|
286 |
|
282 |
287 |
if(areaStyles.size() > 0){
|
283 |
288 |
parameters.put("as", StringUtils.join(areaStyles.iterator(), VALUE_LIST_ENTRY_SEPARATOR));
|
284 |
289 |
}
|
285 |
290 |
if(legendLabels.size() > 0){
|
286 |
291 |
parameters.put("title", StringUtils.join(legendLabels.iterator(), VALUE_LIST_ENTRY_SEPARATOR));
|
287 |
292 |
}
|
288 |
|
|
|
293 |
|
289 |
294 |
// area data
|
290 |
295 |
List<String> stylesPerLayer;
|
291 |
296 |
List<String> areasPerStyle;
|
... | ... | |
306 |
311 |
}
|
307 |
312 |
perLayerAreaData.add(encode(layerString) + ID_FROM_VALUES_SEPARATOR + StringUtils.join(stylesPerLayer.iterator(), VALUE_LIST_ENTRY_SEPARATOR));
|
308 |
313 |
}
|
309 |
|
|
|
314 |
|
310 |
315 |
if(generateMultipleAreaDataParameters){
|
311 |
316 |
// not generically possible since parameters can not contain duplicate keys with value "ad"
|
312 |
317 |
} else {
|
... | ... | |
315 |
320 |
|
316 |
321 |
String queryString = makeQueryString(parameters);
|
317 |
322 |
logger.debug("getDistributionServiceRequestParameterString(): " + queryString);
|
318 |
|
|
|
323 |
|
319 |
324 |
return queryString;
|
320 |
325 |
}
|
321 |
326 |
|
322 |
327 |
private static void groupStylesAndLayers(Set<Distribution> distributions,
|
323 |
328 |
Map<String, Map<Integer, Set<Distribution>>> layerMap,
|
324 |
329 |
List<PresenceAbsenceTermBase<?>> statusList) {
|
|
330 |
|
325 |
331 |
//iterate through distributions and group styles and layers
|
326 |
332 |
//and collect necessary information
|
327 |
333 |
for (Distribution distribution:distributions){
|
... | ... | |
333 |
339 |
if (! statusList.contains(status)){
|
334 |
340 |
statusList.add(status);
|
335 |
341 |
}
|
336 |
|
//group by layers and styles
|
|
342 |
//group areas by layers and styles
|
337 |
343 |
NamedArea area = distribution.getArea();
|
338 |
|
if (area != null){
|
339 |
|
String geoLayerString = getWMSLayerName(area);
|
340 |
|
if(geoLayerString != null){
|
341 |
|
Map<Integer, Set<Distribution>> styleMap = layerMap.get(geoLayerString);
|
342 |
|
if (styleMap == null){
|
343 |
|
styleMap = new HashMap<Integer, Set<Distribution>>();
|
344 |
|
layerMap.put(geoLayerString, styleMap);
|
345 |
|
}
|
346 |
|
addDistributionToMap(distribution, styleMap, statusList);
|
|
344 |
|
|
345 |
addArea(layerMap, statusList, distribution, area);
|
|
346 |
|
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
/**
|
|
351 |
* @param layerMap
|
|
352 |
* @param statusList
|
|
353 |
* @param distribution
|
|
354 |
* @param area
|
|
355 |
*/
|
|
356 |
private static void addArea(Map<String, Map<Integer, Set<Distribution>>> layerMap, List<PresenceAbsenceTermBase<?>> statusList,
|
|
357 |
Distribution distribution, NamedArea area) {
|
|
358 |
|
|
359 |
if (area != null){
|
|
360 |
String geoLayerString = getWMSLayerName(area);
|
|
361 |
|
|
362 |
if(geoLayerString == null){
|
|
363 |
|
|
364 |
// if no layer is mapped this area descend into sub areas in order to project
|
|
365 |
// the distribution to those
|
|
366 |
for(NamedArea subArea : area.getIncludes()){
|
|
367 |
addArea(layerMap, statusList, distribution, subArea);
|
|
368 |
}
|
|
369 |
|
|
370 |
} else {
|
|
371 |
|
|
372 |
Map<Integer, Set<Distribution>> styleMap = layerMap.get(geoLayerString);
|
|
373 |
if (styleMap == null) {
|
|
374 |
styleMap = new HashMap<Integer, Set<Distribution>>();
|
|
375 |
layerMap.put(geoLayerString, styleMap);
|
347 |
376 |
}
|
|
377 |
addDistributionToMap(distribution, styleMap, statusList);
|
|
378 |
|
348 |
379 |
}
|
349 |
380 |
}
|
350 |
381 |
}
|
351 |
382 |
|
|
383 |
|
352 |
384 |
private static String compileMapSizeParameterValue(int width, int height) {
|
353 |
385 |
|
354 |
386 |
String widthStr = "";
|
... | ... | |
381 |
413 |
}
|
382 |
414 |
return encoded;
|
383 |
415 |
}
|
384 |
|
|
|
416 |
|
385 |
417 |
/**
|
386 |
418 |
* combine parameter into a URI query string fragment. The values will be
|
387 |
419 |
* escaped correctly.
|
388 |
|
*
|
|
420 |
*
|
389 |
421 |
* @param parameters
|
390 |
422 |
* @return a URI query string fragment
|
391 |
423 |
*/
|
... | ... | |
396 |
428 |
queryString.append('&');
|
397 |
429 |
}
|
398 |
430 |
if(key.equals("od") || key.equals("os") || key.equals("ms") || key.equals("ad") || key.equals("as") || key.equals("title") || key.equals("bbox")){
|
399 |
|
queryString.append(key).append('=').append(parameters.get(key));
|
|
431 |
queryString.append(key).append('=').append(parameters.get(key));
|
400 |
432 |
} else {
|
401 |
433 |
queryString.append(key).append('=').append(encode(parameters.get(key)));
|
402 |
434 |
}
|
403 |
435 |
}
|
404 |
436 |
return queryString.toString();
|
405 |
437 |
}
|
406 |
|
|
|
438 |
|
407 |
439 |
private static String getAreaAbbrev(Distribution distribution){
|
408 |
440 |
NamedArea area = distribution.getArea();
|
409 |
441 |
Representation representation = area.getRepresentation(Language.DEFAULT());
|
... | ... | |
413 |
445 |
}
|
414 |
446 |
return CdmUtils.Nz(areaAbbrev, "-");
|
415 |
447 |
}
|
416 |
|
|
417 |
448 |
|
418 |
|
//Preliminary as long as user defined areas are not fully implemented
|
|
449 |
|
|
450 |
//Preliminary as long as user defined areas are not fully implemented
|
419 |
451 |
public static final UUID uuidCyprusDivisionsVocabulary = UUID.fromString("2119f610-1f93-4d87-af28-40aeefaca100");
|
420 |
|
|
421 |
|
private static String getWMSLayerName(NamedArea area){
|
|
452 |
|
|
453 |
private static List<String> projectToWMSSubLayer(NamedArea area){
|
|
454 |
|
|
455 |
List<String> layerNames = new ArrayList<String>();
|
|
456 |
String matchedLayerName = null;
|
422 |
457 |
TermVocabulary<NamedArea> voc = area.getVocabulary();
|
423 |
458 |
//TDWG areas
|
424 |
459 |
if (voc.getUuid().equals(TdwgArea.uuidTdwgAreaVocabulary)){
|
425 |
460 |
NamedAreaLevel level = area.getLevel();
|
426 |
461 |
if (level != null) {
|
427 |
|
//TODO integrate into CDM
|
|
462 |
//TODO integrate into CDM
|
|
463 |
if (level.equals(NamedAreaLevel.TDWG_LEVEL1())) {
|
|
464 |
matchedLayerName = "tdwg1" ;
|
|
465 |
} else if (level.equals(NamedAreaLevel.TDWG_LEVEL2())) {
|
|
466 |
matchedLayerName = "tdwg2";
|
|
467 |
}else if (level.equals(NamedAreaLevel.TDWG_LEVEL3())) {
|
|
468 |
matchedLayerName = "tdwg3";
|
|
469 |
}else if (level.equals(NamedAreaLevel.TDWG_LEVEL4())) {
|
|
470 |
matchedLayerName = "tdwg4";
|
|
471 |
}
|
|
472 |
}
|
|
473 |
//unrecognized tdwg area
|
|
474 |
|
|
475 |
}
|
|
476 |
//TODO hardcoded for cyprus (as long as user defined areas are not fully implemented). Remove afterwards.
|
|
477 |
if (voc.getUuid().equals(uuidCyprusDivisionsVocabulary)){
|
|
478 |
matchedLayerName = "cyprusdivs:bdcode";
|
|
479 |
}
|
|
480 |
|
|
481 |
// check if the matched layer equals the layer to project to
|
|
482 |
// if not: recurse into the sub-level in order to find the specified one.
|
|
483 |
String[] matchedLayerNameTokens = StringUtils.split(matchedLayerName, ':');
|
|
484 |
// if(matchedLayerNameTokens.length > 0 && matchedLayerNameTokens[0] != projectToLayer){
|
|
485 |
// for (NamedArea subArea : area.getIncludes()){
|
|
486 |
//
|
|
487 |
// }
|
|
488 |
//
|
|
489 |
// add all sub areas
|
|
490 |
// }
|
|
491 |
|
|
492 |
return null;
|
|
493 |
}
|
|
494 |
|
|
495 |
private static String getWMSLayerName(NamedArea area){
|
|
496 |
TermVocabulary<NamedArea> voc = area.getVocabulary();
|
|
497 |
//TDWG areas
|
|
498 |
if (false && voc.getUuid().equals(TdwgArea.uuidTdwgAreaVocabulary)){
|
|
499 |
NamedAreaLevel level = area.getLevel();
|
|
500 |
if (level != null) {
|
|
501 |
//TODO integrate into CDM
|
428 |
502 |
if (level.equals(NamedAreaLevel.TDWG_LEVEL1())) {
|
429 |
503 |
return "tdwg1";
|
430 |
504 |
} else if (level.equals(NamedAreaLevel.TDWG_LEVEL2())) {
|
... | ... | |
437 |
511 |
}
|
438 |
512 |
//unrecognized tdwg area
|
439 |
513 |
return null;
|
440 |
|
|
|
514 |
|
441 |
515 |
}
|
442 |
516 |
//hardcoded for cyprus (as long as user defined areas are not fully implemented). Remove afterwards.
|
443 |
517 |
if (voc.getUuid().equals(uuidCyprusDivisionsVocabulary)){
|
... | ... | |
445 |
519 |
}
|
446 |
520 |
return null;
|
447 |
521 |
}
|
448 |
|
|
449 |
|
|
|
522 |
|
|
523 |
|
450 |
524 |
private static void addDistributionToMap(Distribution distribution, Map<Integer, Set<Distribution>> styleMap,
|
451 |
525 |
List<PresenceAbsenceTermBase<?>> statusList) {
|
452 |
526 |
PresenceAbsenceTermBase<?> status = distribution.getStatus();
|
... | ... | |
461 |
535 |
}
|
462 |
536 |
distributionSet.add(distribution);
|
463 |
537 |
}
|
464 |
|
|
|
538 |
|
465 |
539 |
/**
|
466 |
540 |
* @param fieldObservationPoints
|
467 |
541 |
* @param derivedUnitPoints
|
... | ... | |
487 |
561 |
List<Point> derivedUnitPoints,
|
488 |
562 |
Map<Class<? extends SpecimenOrObservationBase>, Color> specimenOrObservationTypeColors,
|
489 |
563 |
Boolean doReturnImage, Integer width, Integer height, String bbox, String backLayer) {
|
490 |
|
|
|
564 |
|
491 |
565 |
specimenOrObservationTypeColors = mergeMaps(getDefaultSpecimenOrObservationTypeColors(), specimenOrObservationTypeColors);
|
492 |
|
|
|
566 |
|
493 |
567 |
Map<String, String> parameters = new HashMap<String, String>();
|
494 |
568 |
parameters.put("legend", "0");
|
495 |
569 |
parameters.put("image", doReturnImage != null && doReturnImage ? "true" : "false");
|
... | ... | |
500 |
574 |
if(width != null || height != null){
|
501 |
575 |
parameters.put("ms", compileMapSizeParameterValue(width, height));
|
502 |
576 |
}
|
503 |
|
|
|
577 |
|
504 |
578 |
Map<String, String> styleAndData = new HashMap<String, String>();
|
505 |
|
|
|
579 |
|
506 |
580 |
addToStyleAndData(fieldObservationPoints, FieldObservation.class, specimenOrObservationTypeColors, styleAndData);
|
507 |
581 |
addToStyleAndData(derivedUnitPoints, DerivedUnit.class, specimenOrObservationTypeColors, styleAndData);
|
508 |
|
|
|
582 |
|
509 |
583 |
parameters.put("os", StringUtils.join(styleAndData.keySet().iterator(), "||"));
|
510 |
584 |
parameters.put("od", StringUtils.join(styleAndData.values().iterator(), "||"));
|
511 |
|
|
|
585 |
|
512 |
586 |
String queryString = makeQueryString(parameters);
|
513 |
|
|
|
587 |
|
514 |
588 |
logger.info(queryString);
|
515 |
|
|
|
589 |
|
516 |
590 |
return queryString;
|
517 |
591 |
}
|
518 |
592 |
|
... | ... | |
526 |
600 |
private static <T, S> Map<T, S> mergeMaps(Map<T, S> defaultMap, Map<T, S> overrideMap) {
|
527 |
601 |
Map<T, S> tmpMap = new HashMap<T, S>();
|
528 |
602 |
tmpMap.putAll(defaultMap);
|
529 |
|
if(overrideMap != null){
|
|
603 |
if(overrideMap != null){
|
530 |
604 |
tmpMap.putAll(overrideMap);
|
531 |
605 |
}
|
532 |
606 |
return tmpMap;
|
... | ... | |
538 |
612 |
Map<Class<? extends SpecimenOrObservationBase>, Color> specimenOrObservationTypeColors, Map<String, String> styleAndData) {
|
539 |
613 |
|
540 |
614 |
//TODO add markerShape and size and Label to specimenOrObservationTypeColors -> Map<Class<SpecimenOrObservationBase<?>>, MapStyle>
|
541 |
|
|
|
615 |
|
542 |
616 |
if(points != null && points.size()>0){
|
543 |
617 |
String style = "c/" + Integer.toHexString(specimenOrObservationTypeColors.get(specimenOrObservationType).getRGB()).substring(2) + "/10/noLabel";
|
544 |
618 |
StringBuilder data = new StringBuilder();
|
... | ... | |
552 |
626 |
styleAndData.put(index + ":" +style, index + ":" +data.toString());
|
553 |
627 |
}
|
554 |
628 |
}
|
555 |
|
|
556 |
|
|
|
629 |
|
|
630 |
|
557 |
631 |
/**
|
558 |
632 |
* transform an integer (style counter) into a valid character representing a style.
|
559 |
633 |
* 0-25 => a-z<br>
|
skipping site-depoy in maven release plugin