예제 #1
0
        public void Test_Export()
        {
            var jsonString =
                "{\"field\":\"geo\",\"polygon_points\":[" +
                "{\"lat\":37.79393211306212,\"lon\":-122.44234633404847}," +
                "{\"lat\":37.779958817339967,\"lon\":-122.43977141339417}," +
                "{\"lat\":37.788031092020155,\"lon\":-122.42925715405579}," +
                "{\"lat\":37.79026946582319,\"lon\":-122.41149020154114}," +
                "{\"lat\":37.79571192027403,\"lon\":-122.40735054016113}," +
                "{\"lat\":37.79393211306212,\"lon\":-122.44234633404847}]}";

            var expected = JsonConvert.DeserializeObject <JObject>(jsonString);

            var actual = new GeoPolygonQuery(new List <Coordinate>
            {
                Coordinate.OfLatLon(37.79393211306212, -122.44234633404847),
                Coordinate.OfLatLon(37.779958817339967, -122.43977141339417),
                Coordinate.OfLatLon(37.788031092020155, -122.42925715405579),
                Coordinate.OfLatLon(37.79026946582319, -122.41149020154114),
                Coordinate.OfLatLon(37.79571192027403, -122.40735054016113),
                Coordinate.OfLatLon(37.79393211306212, -122.44234633404847)
            }).Field("geo").Export();

            Assert.Equal(expected, actual);
        }
예제 #2
0
        /// <summary>
        /// 查询表中geo_type_col这一列的值在一个给定多边形范围内的数据。
        /// </summary>
        /// <param name="client"></param>
        public static void GeoPolygonQuery(OTSClient client)
        {
            Console.WriteLine("\n Start GeoPolygon query...");

            SearchQuery     searchQuery     = new SearchQuery();
            GeoPolygonQuery geoPolygonQuery = new GeoPolygonQuery();  // 设置查询类型为GeoPolygonQuery

            geoPolygonQuery.FieldName = Geo_type_col;
            geoPolygonQuery.Points    = new List <string>()
            {
                "0,0", "10,0", "10,10"
            };                                                                      // 设置多边形的顶点
            searchQuery.Query = geoPolygonQuery;

            SearchRequest searchRequest = new SearchRequest(TableName, IndexName, searchQuery);

            ColumnsToGet columnsToGet = new ColumnsToGet();

            columnsToGet.Columns = new List <string>()
            {
                Geo_type_col
            };                                                           //设置返回Col_GeoPoint这一列
            searchRequest.ColumnsToGet = columnsToGet;

            SearchResponse response = client.Search(searchRequest);

            Console.WriteLine(response.TotalCount);
            foreach (var row in response.Rows)
            {
                PrintRow(row);
            }
        }
예제 #3
0
 public static GeoPolygonQuery BuildGeoPolygonQuery(Aliyun.TableStore.DataModel.Search.Query.GeoPolygonQuery query)
 {
     GeoPolygonQuery.Builder builder = GeoPolygonQuery.CreateBuilder();
     builder.SetFieldName(query.FieldName);
     builder.AddRangePoints(query.Points);
     return(builder.Build());
 }