Skip to content

Commit

Permalink
fix: api/maps/uid/data return error 500 (#17818)
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyen authored Jun 21, 2024
1 parent 247e8bd commit 18afa07
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
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

0 comments on commit 18afa07

Please sign in to comment.