koop icon indicating copy to clipboard operation
koop copied to clipboard

False Console Warnings

Open AvidDabbler opened this issue 3 years ago • 2 comments

Hey I am having a couple of issues with working with non date numbers that are unique id's where Koop is interpreting them as Dates. I am also working with a date that Koop interprets as a number. Is there TypeScript Support or a way to manually configure the data types?

AvidDabbler avatar Apr 30 '21 03:04 AvidDabbler

I have found the information for adding in the data types manually in the documentation, but I think that there might be a typo in the docs and I am seeing errors in the console saying that there are missing fields that I have specified now.

The (docs)[https://koopjs.github.io/docs/development/provider/model#adding-provider-metadata-to-the-geojson] talk about adding 'metadata', but in this section it says that the 'fields' key needs to be in properties. Could you clarify whether or not this is supposed to be metadata? I am assuming it is because when I add in the fields key to the metadata object it spits out the errors that I mentioned. I am not sure, but I am thinking that this might have to do with an Async issue in my model. The errors complain about missing fields that are specified in the metadata.fields array:

WARNING: requested provider's metadata field "trip_id (Integer)" not found in feature properties)
WARNING: requested provider's metadata field "vehicle_id (Integer)" not found in feature properties)
WARNING: requested provider's metadata field "start_date (Date)" not found in feature properties)
WARNING: requested provider's metadata field "schedule_relationship (String)" not found in feature properties)
WARNING: requested provider's features have property "route_id (String)" that was not defined in metadata fields array)
WARNING: provider's "idField" is set to OBJECTID, but this field is not defined in metadata.fields

*This warning seems to be coming from the @koopjs/cli/node_modules/featureserver/lib/query.js file on line 151.

I am providing my model a features reduce function that calls other functions to link up 2 different data streams. This is also causing another error where a field is not returning and I am wondering if this could be an Async issue. Below is how I am putting together the geojson.

 const convertToGeoJSON = async (d, trip_updates) => {
      let id = 0
      let features = Object.keys(d).reduce((array, el) => {
        // reorganize geometry sections
        let trip_id = d[el].vehicle.trip.trip_id.toString();
        
        const findDelay = (trip_id, trip_up) => {
          trip_up.forEach(veh => {
            if('#' + trip_id == '#' + veh.trip_update.stop_time_update[0].departure.delay){
              console.log(here)
              return `${veh.trip_update.stop_time_update[0].departure.delay} sec`
            }
          })
        }

        if(!trip_id) return array;
        
        let feature = {
          idField: id,
          OBJECTID: parseInt(id),
          id: id,
          type: 'Feature',
          geometry: {
            type: 'Point',
            coordinates: [d[el].vehicle.position.longitude, d[el].vehicle.position.latitude]
          },
          properties: {
            OBJECTID: id,
            trip_id: trip_id,
            vehicle_id: d[el].vehicle.vehicle.id,
            route_id: d[el].vehicle.trip.route_id,
            direction_id: d[el].vehicle.trip.direction_id,
            start_time: d[el].vehicle.trip.start_time,
            start_date: new Date(d[el].vehicle.trip.start_date),
            schedule_relationship: d[el].vehicle.trip.schedule_relationship,
            label: d[el].vehicle.trip.label,
            timestamp: d[el].vehicle.timestamp,
            delay: findDelay(trip_id, trip_updates),
           
            }
          }

        array.push(feature);
        id = id + 1
        return array
      }, [])
    
      return {
          type: 'FeatureCollection',
          features: features,
          metadata: {
            idField: 'OBJECTID',
            fields: [
              {name: 'trip_id', type: 'Integer'},
              {name: 'vehicle_id', type: 'Integer'},
              {name: 'direction_id', type: 'Integer'},
              {name: 'start_time', type: 'String'},
              {name: 'start_date', type: 'Date'},
              {name: 'schedule_relationship', type: 'String'},
              {name: 'label', type: 'String'},
              {name: 'timestamp', type: 'Date'},
              {name: 'delay', type: 'String'}
             ]
          }
        }   
    }

AvidDabbler avatar Apr 30 '21 13:04 AvidDabbler

Issues have been resolved with the Async task issues. Problem was with using an async reduce function. Console warnings still persist.

WARNING: requested provider's metadata field "trip_id (Integer)" not found in feature properties)
WARNING: requested provider's metadata field "vehicle_id (Integer)" not found in feature properties)
WARNING: requested provider's metadata field "start_date (Date)" not found in feature properties)
WARNING: requested provider's metadata field "schedule_relationship (String)" not found in feature properties)
WARNING: requested provider's features have property "route_id (String)" that was not defined in metadata fields array)
WARNING: provider's "idField" is set to OBJECTID, but this field is not defined in metadata.fields

AvidDabbler avatar May 03 '21 13:05 AvidDabbler

Hello @AvidDabbler - sorry I missed this when first posted. There's been quite a bit of refactoring and several releases since this was posted. Are you still using Koop, and if so, wondering if you are still experiencing this. Koop is now published as @koopjs/koop-core and is on version 8.0.2.

rgwozdz avatar Mar 17 '23 21:03 rgwozdz

No I’m not using Koop anymore. I pivoted away from Koop but was working on building a data lake query with aws Athena.

On Fri, Mar 17, 2023 at 4:20 PM Rich Gwozdz @.***> wrote:

Hello @AvidDabbler https://github.com/AvidDabbler - sorry I missed this when first posted. There's been quite a bit of refactoring and several releases since this was posted. Are you still using Koop, and if so, wondering if you are still experiencing this. Koop is now published as @koopjs/koop-core and is on version 8.0.2.

— Reply to this email directly, view it on GitHub https://github.com/koopjs/koop/issues/375#issuecomment-1474413022, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAUJTHFF4RPFXCNVCZQNT3W4TIQJANCNFSM433HC53A . You are receiving this because you were mentioned.Message ID: @.***>

AvidDabbler avatar Mar 17 '23 22:03 AvidDabbler