Details
Description
We have a case where several labels for polygon geometries are not rendered due to the fact that they don't score high enough in the goodness fit algorithm. Since spaceAround and group can be changed via options (by VendorOption) the goodness fit threshold value should too imho. Not able to post a proper patch unfortunately but the changes are pretty small:
- Add variable, getter and setter for the threshold value in LabelCacheItem.java.
- Add a method to get the value in LabelCacheDefault similar to isGrouping/getSpaceAround:
private double getMinGoodnessFit(TextSymbolizer symbolizer) {
String value = symbolizer.getOption("minGoodnessFit");
if (value == null)
return DEFAULT_MIN_GOODNESS_FIT;
try {
return Double.parseDouble(value);
} catch (Exception e) {
return DEFAULT_MIN_GOODNESS_FIT;
}
}
- set the value on the labelItem in the put()-method:
item.setMinGoodnessFit(getMinGoodnessFit(symbolizer));
- Change the check in the end()-method to something like:
double minGoodnessFit = labelItem.getMinGoodnessFit();
// <= 0 means no check for goodness fit
if (minGoodnessFit > 0 && goodnessOfFit(glyphVector, tempTransform,
representativeGeom) < minGoodnessFit)
continue;