js-jsonq icon indicating copy to clipboard operation
js-jsonq copied to clipboard

How to process geoJSON structures ?

Open wolfgangvonludwigsburg opened this issue 1 year ago • 0 comments

Hi Ahmed, I would like to process geoJSON structures, like so:

    const json = {
        "features": [
            {
                "type"          : "Feature",
                "properties"   : {
                    "str_schl"     : "02505",
                    "baumgruppe"   : "Tilia"
                },
                "geometry"     : {
                    "type"         : "Point",
                    "coordinates"  : [ 7.612346614095637, 51.974634186495123 ]
                }
            },
            {
                //2nd flat record included for test purposes ..
                "type"          : "Feature",
                "str_schl"     : "02505",
                "lat"          : 51,
                "lon"          : 7
            }
        ]
    }

    //
    Q = Q.reset()
    const features = Q.from( 'features' )
        .where( 'properties.str_schl'   , '=', '02505' )    //? no success
      //.where( 'coordinates.0'         , '=', 7 )          //? no success

      //.where( 'type'                  , '=', 'Feature' )  //OK, flat found
      //.where( 'str_schl'              , '=', '02505' )    //OK, flat found
      //.where( 'lat'                   , '>', 50 )         //OK, flat found
      //.where( 'lon'                   , '<', 8 )          //OK, flat found
        .fetch()
    console.log('-------- features from where ---------')
    features.forEach( feature=>console.log( feature ) )

May I ask: (1) How can I access "deep" keys like "str_schl" within "properties" : .. ? (2) or getting "coordinates" i.e. [lon, lat] within "geometry": .. ?

For any advice/hints thanks in advance Wolfgang

wolfgangvonludwigsburg avatar Nov 13 '24 19:11 wolfgangvonludwigsburg