Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface SpatialDataHandling {

String processSpatialPayload(byte[] byteArray) throws IOException, ParseException;

String buildSpatialDescriptorJSON(Integer srid, String type, Double sizeMB, String dimension);

List<DataType> getGeoJsonEnums();

DataType getGeometryType(byte[] byteArray) throws ParseException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public String processSpatialPayload(byte[] byteArray) {
/**
* Builds lightweight spatial descriptor JSON for UI consumption.
*/
private String buildSpatialDescriptorJSON(Integer srid, String type, Double sizeMB, String dimension) {
public String buildSpatialDescriptorJSON(Integer srid, String type, Double sizeMB, String dimension) {

SpatialDataDescriptor descriptor = new SpatialDataDescriptor();
descriptor.setSrid(srid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import org.eea.interfaces.vo.recordstore.enums.ProcessTypeEnum;
import org.eea.multitenancy.TenantResolver;
import org.eea.utils.LiteralConstants;
import org.geolatte.geom.G2D;
import org.geolatte.geom.Geometry;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.annotations.QueryHints;
Expand Down Expand Up @@ -377,6 +379,12 @@ public class RecordRepositoryImpl implements RecordExtendedQueriesRepository {
private static final String RECORD_JSON_QUERY = "SELECT record_json from dataset_%s.temp_etlexport "
+ "WHERE filter_value= ? and id>= ? and id< ?";

private static final List<String> AFFECTED_TYPES = Arrays.asList(
DataType.POLYGON.getValue(),
DataType.MULTIPOLYGON.getValue(),
DataType.GEOMETRYCOLLECTION.getValue()
);

/**
* Find by table value with order.
*
Expand Down Expand Up @@ -1312,6 +1320,24 @@ private List<RecordValue> sanitizeRecords(List<RecordValue> records, String data
String idPk = (referenced != null) ? referenced.get("idPk").toString() : null;
fieldValue.setReferenceFieldSchemaId(idPk);
}
if (AFFECTED_TYPES.contains(fieldValue.getType().getValue())) {
// starting with this type of geometry to extract valuable info
//{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[...]}
Geometry<G2D> geometry = fieldValue.getGeometry();
if (geometry != null) {
final double BYTES_IN_MB = 1024.0 * 1024.0; // conversion factor bytes -> megabytes

String type = geometry.getGeometryType().toString();
int srid = geometry.getSRID();
int dimensions = geometry.getDimension();

final int sizeBytes = fieldValue.getValue().getBytes(StandardCharsets.UTF_8).length;
final double sizeMB = Math.round((sizeBytes / BYTES_IN_MB) * 100.0) / 100.0;

String jsonValue = spatialDataHandling.buildSpatialDescriptorJSON(srid, type, sizeMB, dimensions +"D");
fieldValue.setValue(jsonValue);
}
}
}
sanitizedRecords.add(recordValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,6 @@ private TableVO calculatedErrorsAndRecordsToSee(final Long datasetId, final Stri
&& (idRules == null || idRules.length == 0) && fieldSchema == null && fieldValue == null) {
records = recordRepository.findByTableValueNoOrder(idTableSchema, pageable);
List<RecordVO> recordVOs = recordNoValidationMapper.entityListToClass(records);
spatialDataHandling.transformSpatialFields(recordVOs);
result.setTotalFilteredRecords(0L);
result.setRecords(recordVOs);
} else {
Expand Down