Product Feature: Query Spatial Data
Issue
User is trying to build a simple Spectrum Location Intelligence Module dataflow that can determine if a point is within a polygon.
They are using the Query Spatial Data stage in whereby we construct MI_Point using Longitude and Latitude values from the input, (in this example long/lat coordinates from a csv. They then use the MI_Within Geometry Predicate Function to determine if the constructed point falls within the specified Named Table.
Below are a few samples of MISQL scripts written within the Query Spatial Data stage:
They are using the Query Spatial Data stage in whereby we construct MI_Point using Longitude and Latitude values from the input, (in this example long/lat coordinates from a csv. They then use the MI_Within Geometry Predicate Function to determine if the constructed point falls within the specified Named Table.
Below are a few samples of MISQL scripts written within the Query Spatial Data stage:
Select Count(*) from "/NamedMaps/NamedTable" Where MI_Within(Obj,MI_Point(${Longitude},${Latitude},'epsg:4326')) |
Select * from "/NamedMaps/NamedTables" Where MI_Within(Obj,MI_Point(${Longitude},${Latitude},'epsg:4326')) |
Cause
MI_Point must be used with data set , where the parameter is a numeric field such as DOUBLE, otherwise the MI_Point cannot create the coordinate geometry that was intended.
Resolution
UPDATED: July 11, 2018Ensure the MI_Point data set is set to type Double.
Ensure the MI_Point parameters are numeric (they do not have to be double)
There are also two other alternatives:
1. Create a point object using the spatial calculator stage and then use the point object in the query .
2. Convert the string to a number explicitly in SQL using the StringToNumber function. MI_Point(StringToNumber( ${Lon}, '9999.999999')…..
Ensure the MI_Point parameters are numeric (they do not have to be double)
There are also two other alternatives:
1. Create a point object using the spatial calculator stage and then use the point object in the query .
2. Convert the string to a number explicitly in SQL using the StringToNumber function. MI_Point(StringToNumber( ${Lon}, '9999.999999')…..