Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: api/maps/uid/data return error 500[DHIS2-12003-39] #17818

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
14 changes: 13 additions & 1 deletion dhis-2/dhis-services/dhis-service-reporting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</dependency>

<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-cql</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.hisp.dhis</groupId>
Expand Down Expand Up @@ -243,6 +250,11 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<scope>test</scope>
</dependency>

<!-- Other -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public SimpleFeatureType getFeatureType() {
}

try {
return DataUtilities.createType(GEOMETRIES, "geometry:" + type + ":srid=3785");
return DataUtilities.createType(GEOMETRIES, "geometry:" + type + ":srid=3857");
} catch (SchemaException ex) {
throw new RuntimeException("failed to create geometry", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@
*/
package org.hisp.dhis.mapgeneration;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.awt.Color;
import java.io.IOException;
import org.geotools.geojson.geom.GeometryJSON;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Geometry;

/**
* @author Kenneth Solbø Andersen <kennetsa@ifi.uio.no>
*/
class GeoToolsMapObjectTest {

private InternalMapObject geoToolsMapObject;
private GeometryJSON geometryJSON = new GeometryJSON();
private String multiPolygonCoordinates =
"[[[[11.11,22.22],[33.33,44.44],[55.55,66.66],[11.11,22.22]]],"
+ "[[[77.77,88.88],[99.99,11.11],[22.22,33.33],[77.77,88.88]]],"
+ "[[[44.44,55.55],[66.66,77.77],[88.88,99.99],[44.44,55.55]]]]";

@BeforeEach
void before() {
Expand Down Expand Up @@ -92,4 +102,16 @@ void testSetGetStrokeColor() {
geoToolsMapObject.setStrokeColor(Color.WHITE);
assertEquals(Color.WHITE, geoToolsMapObject.getStrokeColor());
}

@Test
void testCreateFeatureType() throws IOException {
Geometry geometry =
geometryJSON.read(
"{\"type\":\"MultiPolygon\", \"coordinates\":" + multiPolygonCoordinates + "}");
geoToolsMapObject.setGeometry(geometry);
assertDoesNotThrow(
() -> {
assertNotNull(MapUtils.createFeatureLayerFromMapObject(geoToolsMapObject));
});
}
}
13 changes: 13 additions & 0 deletions dhis-2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,16 @@
<artifactId>gt-referencing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-cql</artifactId>
<version>${geotools.version}</version>
</dependency>

<!-- JAXB -->
<dependency>
Expand Down Expand Up @@ -2003,6 +2013,9 @@ jasperreports.version=${jasperreports.version}
<failOnWarning>true</failOnWarning>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>org.projectlombok:lombok</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.geotools:gt-main</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.geotools:gt-epsg-hsql</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.geotools:gt-cql</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.springframework.security:spring-security-core</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>net.sf.jasperreports:jasperreports</ignoredUnusedDeclaredDependency>
Expand Down
Loading