Query in a geometry column (created by kml file)?

你。 提交于 2019-12-11 05:47:54

问题


If you query with

contains ignore case

then the query will return the data, but does so slowly.

How I can query in a geometry column in a fusion table?

I created a kml file with Google Maps, which was imported to Google fusion table. When I try to search the longitude & latitude in the column geometry to return the names of the zones where longitude & latitude match in one or more points inside the polyline.

The geometry column in my case stores a polyline like this:

Current cell value:

<LineString><coordinates>
-99.832771,16.88472,0.0
-99.832703,16.88558,0.0
-99.832703,16.88558,0.0
-99.831383,16.885441,0.0 
..... 
</coordinates></LineString>

Now I try query tableid = 3427749:

http://fusiontables.googleusercontent.com/fusiontables/api/query?sql=
SELECT name FROM 3427749 
WHERE ST_INTERSECTS('geometry',RECTANGLE(LATLNG(32.618591,-115.441528),LATLNG(31.954109,-115.212509)))

and return void but if you try paint the same coordinates in a rectangle you can see it well and if you look the table, this region contains valid coordinates for my query.

Painting the same region:


 var boudns = new google.maps.LatLngBounds(new google.maps.LatLng(32.618591, -115.441528),    new google.maps.LatLng(31.954109,-115.212509));

 var rectOptions = {
          strokeColor: "#000000",
          strokeOpacity: 0.6,
          strokeWeight: 2,
          fillColor: "#000000",
          fillOpacity: 0.2,
          bounds: boudns
        };
 rect.setOptions(rectOptions);

 var myOptions = {
      center: new google.maps.LatLng(23.926013,-101.90918),
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
 map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

 rect.setMap(map);

//You need implement a div with id map_canvas and put the code in `<script>` tags.

What is wrong? Any help, please?


回答1:


You have your latitudes wrong in your search RECTANGLE.

From the FT SELECT Reference Docs

The syntax is: RECTANGLE(<lower_left_corner>, <upper_right_corner>)

You have:

ST_INTERSECTS('geometry',RECTANGLE(LATLNG(32.618591,-115.441528),LATLNG(31.954109,-115.212509)))

Latitude 32.618591 > 31.954109 When I switched these latitudes and ran your query I got one name "Mexicali - El Faro"



来源:https://stackoverflow.com/questions/10035250/query-in-a-geometry-column-created-by-kml-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!