diff --git a/here-naksha-lib-psql/src/commonMain/kotlin/naksha/psql/executors/write/WriteFeatureUtils.kt b/here-naksha-lib-psql/src/commonMain/kotlin/naksha/psql/executors/write/WriteFeatureUtils.kt index bdeb95a2c..e34cc5951 100644 --- a/here-naksha-lib-psql/src/commonMain/kotlin/naksha/psql/executors/write/WriteFeatureUtils.kt +++ b/here-naksha-lib-psql/src/commonMain/kotlin/naksha/psql/executors/write/WriteFeatureUtils.kt @@ -96,7 +96,7 @@ internal object WriteFeatureUtils { feature = PgUtil.encodeFeature(feature, flags, encodingDict), tags = PgUtil.encodeTags( feature.properties.xyz.tags?.toTagMap(), - storage.defaultFlags, + flags, encodingDict ), attachment = attachment, diff --git a/here-naksha-lib-psql/src/commonTest/kotlin/naksha/psql/SridTest.kt b/here-naksha-lib-psql/src/commonTest/kotlin/naksha/psql/SridTest.kt index 901066e85..8d9ce1bbf 100644 --- a/here-naksha-lib-psql/src/commonTest/kotlin/naksha/psql/SridTest.kt +++ b/here-naksha-lib-psql/src/commonTest/kotlin/naksha/psql/SridTest.kt @@ -7,6 +7,8 @@ import naksha.geo.SpLineString import naksha.model.* import naksha.model.GeoEncoding.GeoEncoding_C.EWKB import naksha.model.GeoEncoding.GeoEncoding_C.EWKB_GZIP +import naksha.model.GeoEncoding.GeoEncoding_C.GEO_JSON +import naksha.model.GeoEncoding.GeoEncoding_C.GEO_JSON_GZIP import naksha.model.GeoEncoding.GeoEncoding_C.TWKB import naksha.model.GeoEncoding.GeoEncoding_C.TWKB_GZIP import naksha.model.GeoEncoding.GeoEncoding_C.WKB @@ -65,6 +67,16 @@ class SridTest : PgTestBase() { encodingName = "EWKB_GZIP", flags = flagsFor(EWKB_GZIP), collectionId = "srid_test_ewkb_gzip" + ), + GEO_JSON to SridTestConfig( + encodingName = "GEO_JSON", + flags = flagsFor(GEO_JSON), + collectionId = "srid_test_geojson" + ), + GEO_JSON_GZIP to SridTestConfig( + encodingName = "GEO_JSON_GZIP", + flags = flagsFor(GEO_JSON_GZIP), + collectionId = "srid_test_geojson_gzip" ) ) } @@ -113,6 +125,16 @@ class SridTest : PgTestBase() { runTestFor(EWKB_GZIP) } + @Test + fun shouldPreserveSridForGeoJson() { + runTestFor(GEO_JSON) + } + + @Test + fun shouldPreserveSridForGeoJsonGzip() { + runTestFor(GEO_JSON_GZIP) + } + private fun runTestFor(encoding: Int) { // Given: test config val testConfig = testConfigs[encoding] diff --git a/here-naksha-lib-psql/src/jvmMain/resources/naksha.sql b/here-naksha-lib-psql/src/jvmMain/resources/naksha.sql index 064a81787..48b2bdc2c 100644 --- a/here-naksha-lib-psql/src/jvmMain/resources/naksha.sql +++ b/here-naksha-lib-psql/src/jvmMain/resources/naksha.sql @@ -249,7 +249,7 @@ BEGIN elsif (encoding = 4) then RETURN ST_GeomFromEWKB(geo); elsif (encoding = 6) then - RETURN ST_GeomFromGeoJSON(geo::text); + RETURN ST_GeomFromGeoJSON(convert_from(geo, 'UTF8')); end if; -- Unknown encoding return null;