DRIVER-EU / MessageInjector

Inject AVRO-based messages into the Kafka Test-bed.
MIT License
0 stars 0 forks source link

Create map that allows to draw and upload GeoJSON #2

Open croser opened 4 years ago

croser commented 4 years ago

Sample for uploaded JSON: geojson.json.zip

croser commented 4 years ago

This has been implemented:

Locally, I still have on issue though - which might be due to the fact that i use testbed adaptor in 1.2.22 and XML JSON to AVRO in 1.0.4. Can you please test on the current versions? Below is what i see.

{
    "type": "FeatureCollection",
    "bbox": null,
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            52.77199981024419,
                            45.73369335022667
                        ],
                        [
                            52.526262907751764,
                            38.6447962321096
                        ],
                        [
                            65.67318719109548,
                            38.6447962321096
                        ],
                        [
                            66.41039789857268,
                            45.21675358266978
                        ],
                        [
                            52.77199981024419,
                            45.73369335022667
                        ]
                    ]
                ]
            },
            "properties": {
            },
            "bbox": null
        }
    ]
}

The following error is logged:

org.apache.avro.AvroTypeException: Expected start-union. Got START_ARRAY
    at org.apache.avro.io.JsonDecoder.error(JsonDecoder.java:698) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:441) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.io.parsing.Parser.advance(Parser.java:88) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:232) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:222) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:175) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153) ~[xml-avro-1.0.3.jar:1.0.3]
    at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:145) ~[xml-avro-1.0.3.jar:1.0.3]
    at eu.driver.adaptor.controller.SendRestController.sendGeoJson(SendRestController.java:227) ~[classes/:na]
thoobr commented 4 years ago

You need to wrap the geometry: { "type": "FeatureCollection", "bbox": null, "features": {"array": [ { "type": "Feature", "bbox": null, "geometry": { "eu.driver.model.geojson.Polygon" : { "type": "Polygon", "coordinates": [ [ [ 16.341400165110826, 48.2764496139113 ], [ 16.234588650986556, 48.14935071777878 ], [ 16.426086430437866, 48.085275205354556 ], [ 16.52069095987827, 48.19422721745656 ], [ 16.42303466331214, 48.270457652931235 ], [ 16.341400165110826, 48.2764496139113 ] ] ]} }, "properties": {} } ]} }