tenthe commented on code in PR #1069:
URL: https://github.com/apache/streampipes/pull/1069#discussion_r1069106276


##########
streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/format/geojson/GeoJsonParser.java:
##########
@@ -85,66 +85,85 @@ public void parse(InputStream data, EmitBinaryEvent 
emitBinaryEvent) throws Pars
 
   @Override
   public EventSchema getEventSchema(List<byte[]> oneEvent) {
-    EventSchema resultSchema = new EventSchema();
+    return this.getSchemaAndSample(oneEvent).getEventSchema();
+  }
+
+  @Override
+  public boolean supportsPreview() {
+    return true;
+  }
+
+  @Override
+  public AdapterGuessInfo getSchemaAndSample(List<byte[]> eventSample) throws 
ParseException {
 
     Feature geoFeature = null;
     try {
-      geoFeature = new ObjectMapper().readValue(oneEvent.get(0), 
Feature.class);
+      geoFeature = new ObjectMapper().readValue(eventSample.get(0), 
Feature.class);
 
     } catch (IOException e) {
       logger.error(e.toString());
     }
 
-    for (Map.Entry<String, Object> entry : 
geoFeature.getProperties().entrySet()) {
-      EventProperty p = JsonEventProperty.getEventProperty(entry.getKey(), 
entry.getValue());
-      resultSchema.addEventProperty(p);
-    }
-
-    List<EventProperty> eventProperties = parseGeometryField(geoFeature);
-    eventProperties.forEach(eventProperty -> 
resultSchema.addEventProperty(eventProperty));
-
-    return resultSchema;
+    return this.parseGeometryField(geoFeature);
   }
 
-  private List<EventProperty> parseGeometryField(Feature geoFeature) {
+  private AdapterGuessInfo parseGeometryField(Feature geoFeature) {
+
+    EventSchema resultSchema = new EventSchema();
     List<EventProperty> eventProperties = new LinkedList<>();
+    var sampleValues = new HashMap<String, GuessTypeInfo>();
 
     if (geoFeature.getGeometry() instanceof Point) {
       Point point = (Point) geoFeature.getGeometry();
       eventProperties.add(getEventPropertyGeoJson("longitude", 
point.getCoordinates().getLongitude(),
           "http://www.w3.org/2003/01/geo/wgs84_pos#long";));
       eventProperties.add(getEventPropertyGeoJson("latitude", 
point.getCoordinates().getLatitude(),
           "http://www.w3.org/2003/01/geo/wgs84_pos#lat";));
+
+      sampleValues.put("longitude", new GuessTypeInfo("java.lang.Double", 
point.getCoordinates().getLongitude()));
+      sampleValues.put("latitude", new GuessTypeInfo("java.lang.Double", 
point.getCoordinates().getLatitude()));
       if (point.getCoordinates().hasAltitude()) {
         eventProperties.add(getEventPropertyGeoJson("altitude", 
point.getCoordinates().getAltitude(), SO.ALTITUDE));
+        sampleValues.put("altitude", new GuessTypeInfo("java.lang.Double", 
point.getCoordinates().getAltitude()));
       }
 
     } else if (geoFeature.getGeometry() instanceof LineString) {
       LineString lineString = (LineString) geoFeature.getGeometry();
       
eventProperties.add(JsonEventProperty.getEventProperty("coorindatesLineString", 
lineString.getCoordinates()));
-
+      sampleValues.put("coorindatesLineString", new 
GuessTypeInfo("java.lang.Double", lineString.getCoordinates()));

Review Comment:
   Thanks, you are right. It seems to be a typo.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to