Bug fixing #25056
This commit is contained in:
parent
fe0869975a
commit
c72f884206
|
@ -174,7 +174,8 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ********************** Updated by Francesco, see #25056, EVALAUTE POSITION
|
// ********************** Updated by Francesco, see #25056, Calculating Spatial Reference as Centroid Object
|
||||||
|
//**** EVALUATE POSITION
|
||||||
log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
||||||
SpatialReference reference = null;
|
SpatialReference reference = null;
|
||||||
List<IdentificationReference> refs = project
|
List<IdentificationReference> refs = project
|
||||||
|
@ -198,12 +199,14 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
||||||
|
|
||||||
centroidDoc.put("geom", wkt);
|
centroidDoc.put("geom", wkt);
|
||||||
|
//No overriding SpatialReference in the IndexDocumentReport, using the existing one.
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
log.info("Is defined spatial reference wrong or empty? " + reference);
|
log.info("The defined spatial reference is wrong or empty: " + reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Calculating and overriding the SpatialReference (the Centroid JSON) in the IndexDocumentReport.
|
||||||
if(bbox==null) {
|
if(bbox==null) {
|
||||||
log.info("No bbox defined in the current spatial reference going to calculate it...");
|
log.info("No bbox defined in the current spatial reference going to calculate it...");
|
||||||
// unable to use current Spatial reference, try evaluating it
|
// unable to use current Spatial reference, try evaluating it
|
||||||
|
@ -253,79 +256,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
report.addIdentificationReference(reference);
|
report.addIdentificationReference(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ********************** EVALAUTE POSITION
|
|
||||||
/*log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
|
||||||
SpatialReference reference = null;
|
|
||||||
List<IdentificationReference> refs = project
|
|
||||||
.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE);
|
|
||||||
if (!refs.isEmpty()) {
|
|
||||||
|
|
||||||
// Use existing Reference
|
|
||||||
|
|
||||||
reference = Serialization.convert(refs.get(0), SpatialReference.class);
|
|
||||||
|
|
||||||
log.debug("Using already defined spatial reference " + reference);
|
|
||||||
|
|
||||||
GeoJsonObject object = Serialization.convert(reference.getGeoJson(), GeoJsonObject.class);
|
|
||||||
|
|
||||||
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.fromGeoJSON(object.getBbox());
|
|
||||||
|
|
||||||
log.info("Found declared BBOX {} ", bbox);
|
|
||||||
Double pointX = (bbox.getMaxX() + bbox.getMinX()) / 2;
|
|
||||||
Double pointY = (bbox.getMaxY() + bbox.getMinY()) / 2;
|
|
||||||
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
|
||||||
|
|
||||||
centroidDoc.put("geom", wkt);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// unable to use current Spatial reference, try evaluating it
|
|
||||||
log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ",
|
|
||||||
useCaseDescriptor.getId());
|
|
||||||
|
|
||||||
// for each configuration option try until found
|
|
||||||
GCubeSDILayer.BBOX toSet = null;
|
|
||||||
for (BBOXEvaluator evaluator : BBOX_EVALUATORS) {
|
|
||||||
log.trace("UCD {}, Project {}. Evaluating BBOX with {}", useCaseDescriptor.getId(), project.getId(),
|
|
||||||
evaluator);
|
|
||||||
try {
|
|
||||||
if (evaluator.isConfigured(profileConfiguration)) {
|
|
||||||
toSet = evaluator.evaluate(profileConfiguration, useCaseDescriptor, documentNavigator);
|
|
||||||
if (toSet != null) {
|
|
||||||
log.info("UCD {}, Project {}. Evaluated BBOX {} with method {}",
|
|
||||||
useCaseDescriptor.getId(), project.getId(), toSet, evaluator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
log.warn("UCD {}, Project {}. Exception with {}", useCaseDescriptor.getId(), project.getId(),
|
|
||||||
evaluator, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (toSet == null)
|
|
||||||
throw new IndexingException("No BBOX has been evaluated from project");
|
|
||||||
|
|
||||||
Double pointX = (toSet.getMaxX() + toSet.getMinX()) / 2;
|
|
||||||
Double pointY = (toSet.getMaxY() + toSet.getMinY()) / 2;
|
|
||||||
log.info("Evaluated BBOX {} ", toSet);
|
|
||||||
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
|
||||||
// TODO support altitude
|
|
||||||
Double pointZ = 0d;
|
|
||||||
|
|
||||||
centroidDoc.put("geom", wkt);
|
|
||||||
|
|
||||||
Point point = new Point();
|
|
||||||
point.setCoordinates(new LngLatAlt(pointX, pointY, pointZ));
|
|
||||||
point.setBbox(toSet.asGeoJSONArray());
|
|
||||||
|
|
||||||
// TODO Manage CRS
|
|
||||||
point.setCrs(new Crs());
|
|
||||||
reference = new SpatialReference(Serialization.asDocument(point));
|
|
||||||
log.info("UCD {} project {}, Setting Spatial Reference {} ", useCaseDescriptor.getId(), project.getId(),
|
|
||||||
Serialization.write(reference));
|
|
||||||
report.addIdentificationReference(reference);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// *********** Additional Values from useCaseDescriptor
|
// *********** Additional Values from useCaseDescriptor
|
||||||
|
|
||||||
log.info("Setting additional values to centroid from mappings ..");
|
log.info("Setting additional values to centroid from mappings ..");
|
||||||
|
@ -412,7 +342,7 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
//***** Added by Francesco, see #25056
|
//***** Added by Francesco, see #25056
|
||||||
//Replacing the "old" centroid if any. Creating an empty SpatialReference
|
//Replacing the "old" centroid if any. Creating an empty SpatialReference
|
||||||
SpatialReference reference = new SpatialReference(new Document());
|
SpatialReference reference = new SpatialReference(new Document());
|
||||||
log.info("UCD {} project {}, Setting Spatial Reference empty {} ", request.getDocument().getId(), Serialization.write(reference));
|
log.info("DeIndexer project {}, Setting Spatial Reference empty {} ", request.getDocument().getId(), Serialization.write(reference));
|
||||||
report.addIdentificationReference(reference);
|
report.addIdentificationReference(reference);
|
||||||
|
|
||||||
} catch (SDIInteractionException e) {
|
} catch (SDIInteractionException e) {
|
||||||
|
|
Loading…
Reference in New Issue