graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Spatial filtering with different EPSG/SRID distance calculation

Open edihasaj opened this issue 2 years ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Is there any way to project spatial data to a desired EPSG/SRID for distance calculation and stuff?

companyCategories(where: {
    company: {
      city: {
        location: {
          distance: {
            geometry: {
              type: Point, 
              coordinates: [21.1655, 42.6629],
              crs: 3035 # this throws The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (\"@__p_0\"): The supplied value is not a valid instance of data type geography.
            },
            lt: 1
          }
        }
      }
    }
  }) {
…
}

Is there any geometryFactory that I can override or something like that? This only works with EPSG WGS84 / 4326. Any help would be appreciated :raised_hands:

Steps to reproduce

Relevant log output

No response

Additional Context?

No response

Product

Hot Chocolate

Version

12.8.1

edihasaj avatar Apr 28 '22 21:04 edihasaj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 28 '22 02:06 stale[bot]

I'm running into the same problem. Any solutions?

robotrick avatar Jul 26 '22 14:07 robotrick

Nope, still nothing..

edihasaj avatar Jul 26 '22 14:07 edihasaj

@robotrick @edihasaj

Did you try to configure the spaital types?

            .AddSpatialTypes(x => x
                .DefaultSrid(4326)
                .AddCoordinateSystem(26918, WKT26918))

alternatively, we've also merged https://github.com/ChilliCream/hotchocolate/pull/5048 into main. This is already available in recent v13 previews

PascalSenn avatar Jul 26 '22 14:07 PascalSenn

No, I didn't try this. I'll try and let you know. Thanks

edihasaj avatar Jul 26 '22 14:07 edihasaj

Will give it a try and come back later, thank you @PascalSenn

robotrick avatar Jul 26 '22 14:07 robotrick

Doesn't work for me, same exception

  .AddSpatialTypes(x => x
                    .DefaultSrid(4326)
                    .AddCoordinateSystemFromString(4326, WKT4326)
                    .AddCoordinateSystemFromString(26918, WKT26918))

the overload for AddCoordinateSystem(number, string) is not avalible in 12.11.1 without .AddCoordinateSystemFromString(4326, WKT4326) throws an error

query:

xyz (
    where: 
    { station: {
       location: 
      { within: 
        { geometry: 
          {
            type: Point, coordinates: [16.376608026996855, 48.18535895537918], lt: 500}
        	}
      	}
    	}
    }
)

error:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (\"@__p_0\"): The supplied value is not a valid instance of data type geography. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.

robotrick avatar Jul 26 '22 15:07 robotrick

@PascalSenn: The fault was mine, sorry. Defining the DefaultSrid() and using "distance" instead of "within" solved my problem.

guess i found a typo in the documentation: https://chillicream.com/docs/hotchocolate/integrations/spatial-data

{
  pubs(
    where: {
      location: {
        within: { geometry: { type: Point, coordinates: [1, 1] }, **lt: 120** }
      }
    }
  ) {
    id
    name
    location
  }
}

lt: doesn't exist at this point.

robotrick avatar Jul 26 '22 17:07 robotrick

Closing, as this appears to have been resolved.

glen-84 avatar Jan 15 '24 09:01 glen-84