/glayer/do_identify

POST

Идентификация объектов в слоях (с фильтром)

/glayer/do_identify (с фильтром)

Получение информации об объекте в слое по указанным координатам с применением фильтра

Дополнительно можно применить фильтр к данным

Для этого нужно иначе сформировать параметр gilayers
Нужно добавить ещё одно свойство Filter

[
  {
    "Id": 101,
    "Filter": [
      {
        "FieldName": "people",
        "Condition": "gte",
        "Value": "500"
      },
      {
        "FieldName": "people",
        "Condition": "lte",
        "Value": "2500"
      }
    ]
  }
]

Условия фильтра - это массив с условиями

Одно условие имеет вот такую структуру

{
  "FieldName": "people",
  "Condition": "gte",
  "Value": "500"
}

Такое условие означает "Численность населения больше или равно 500"

FieldName - Имя поля в слое

Value - Значение, числовое или текстовое

Condition - Условие "больше или равно", "меньше или равно" и т.д.

Condition бывают следующие:

Условие Расшифровка Что значит
gte Greater Then Or Equal Больше или равно
lte Less Then Or Equal Меньше или равно
eq Equal Равно
like Like Похоже на ... (ниже подробнее)
in In list Есть в списке (список через запятую, ниже подробнее)

Подробнее

Пример like

{
  "FieldName": "type",
  "Condition": "like",
  "Value": "*дуктов"
}

будет показывать только то, что заканчивается на дуктов
например, магазин продуктов

Пример in

{
  "FieldName": "type",
  "Condition": "in",
  "Value": "магазин продуктов,парикмахерская"
}

будет показывать информацию только из объектов, у которых тип равен либо магазин продуктов, либо парикмахерская

Headers

ccode
text
request_user_007
CCODE - (Client Code) - Обязательный параметр. Это идентификатор клиента в свободной форме. Он нужн для того, чтобы понять, кто именно выполнил запрос. Обычно, если API пользуются несколько пользователей, то сюда указывают ID пользователя, например, user_56748 Если так сделать, то мы сможем по логам понять, например, кто именно настрелял слишком много запросов
key
text
dd83e51f-6d0a-4510-a885-6b54e5881961
Обязательный параметр. Ключ доступа к API. Этот ключ даёт доступ лишь к демонстрационному датасету и набору функций. Реальный ключ выдается при оформлении платной подписки на Geointellect

Body

URLENCODED
xlon
37.517023
Долгота (в десятичных градусах)
ylat
55.662627
Широта (в десятичных градусах)
zoom
14
Уровень приближения к карте
aswgs
true
По-умолчанию true, если false, то результат вернется в метрах (EPSG 3857)
gilayers
[ { "Id": 101, "Filter": [ { "FieldName": "people", "Condition": "gte", "Value": "500" }, { "FieldName": "people", "Condition": "lte", "Value": "2500" } ] } ]
JSON. Массив слоёв, в которых нужно идентифицировать объекты
Примеры запросов
curl -X POST \
  -L 'https://api.geointellect.com/glayer/do_identify' \
  -H 'ccode: request_user_007' \
  -H 'key: dd83e51f-6d0a-4510-a885-6b54e5881961' \
  --data-urlencode 'xlon=37.517023' \
  --data-urlencode 'ylat=55.662627' \
  --data-urlencode 'zoom=14' \
  --data-urlencode 'aswgs=true' \
  --data-urlencode 'gilayers=%5b%0a++%7b%0a++++%22Id%22%3a+101%2c%0a++++%22Filter%22%3a+%5b%0a++++++%7b%0a++++++++%22FieldName%22%3a+%22people%22%2c%0a++++++++%22Condition%22%3a+%22gte%22%2c%0a++++++++%22Value%22%3a+%22500%22%0a++++++%7d%2c%0a++++++%7b%0a++++++++%22FieldName%22%3a+%22people%22%2c%0a++++++++%22Condition%22%3a+%22lte%22%2c%0a++++++++%22Value%22%3a+%222500%22%0a++++++%7d%0a++++%5d%0a++%7d%0a%5d'  \
  -v
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;

public class Program
{
    public static async Task Main(string[] args)
    {
        var client = new HttpClient();
        var request = new HttpRequestMessage(HttpMethod.Post, "https://api.geointellect.com/glayer/do_identify");
        request.Headers.Add("ccode", "request_user_007");
        request.Headers.Add("key", "dd83e51f-6d0a-4510-a885-6b54e5881961");
        
        var collection = new List<KeyValuePair<string, string>>();
        collection.Add(new("xlon", "37.517023"));
        collection.Add(new("ylat", "55.662627"));
        collection.Add(new("zoom", "14"));
        collection.Add(new("aswgs", "true"));
        collection.Add(new("gilayers", @"
                             [
                               {
                                 ""Id"": 101,
                                 ""Filter"": [
                                   {
                                     ""FieldName"": ""people"",
                                     ""Condition"": ""gte"",
                                     ""Value"": ""500""
                                   },
                                   {
                                     ""FieldName"": ""people"",
                                     ""Condition"": ""lte"",
                                     ""Value"": ""2500""
                                   }
                                 ]
                               }
                             ]"));
        
        var data = new FormUrlEncodedContent(collection);
        
        request.Content = data;
        var response = await client.SendAsync(request);
        response.EnsureSuccessStatusCode();
        Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
}
import requests
import json

url = "https://api.geointellect.com/glayer/do_identify"

headers = {
    'ccode': 'request_user_007',
    'key': 'dd83e51f-6d0a-4510-a885-6b54e5881961',
}

# URL-encoded form data
data = {
    'xlon': '37.517023',
    'ylat': '55.662627',
    'zoom': '14',
    'aswgs': 'true',
    'gilayers': '[
  {
    "Id": 101,
    "Filter": [
      {
        "FieldName": "people",
        "Condition": "gte",
        "Value": "500"
      },
      {
        "FieldName": "people",
        "Condition": "lte",
        "Value": "2500"
      }
    ]
  }
]',
}

response = requests.post(url, headers=headers, data=data)

# Check response and print result
response.raise_for_status()
print(response.text)
const headers = {
  'ccode': 'request_user_007',
  'key': 'dd83e51f-6d0a-4510-a885-6b54e5881961',
};

const options = {
  method: 'POST',
  headers: headers,
  body: new URLSearchParams({
    'xlon': '37.517023',
    'ylat': '55.662627',
    'zoom': '14',
    'aswgs': 'true',
    'gilayers': '[
  {
    "Id": 101,
    "Filter": [
      {
        "FieldName": "people",
        "Condition": "gte",
        "Value": "500"
      },
      {
        "FieldName": "people",
        "Condition": "lte",
        "Value": "2500"
      }
    ]
  }
]',
  }),
};

fetch('https://api.geointellect.com/glayer/do_identify', options)
  .then(response => {
    if (!response.ok) {
      throw new Error('HTTP error ' + response.status);
    }
    return response.json();
  })
  .then(data => console.log('Success:', data))
  .catch(error => console.error('Error:', error));
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
)

func main() {
    client := &http.Client{
    }

    baseUrl := "https://api.geointellect.com/glayer/do_identify"
    fullUrl := baseUrl

    formData := url.Values{
        "xlon": {"37.517023"},
        "ylat": {"55.662627"},
        "zoom": {"14"},
        "aswgs": {"true"},
        "gilayers": {"[
  {
    "Id": 101,
    "Filter": [
      {
        "FieldName": "people",
        "Condition": "gte",
        "Value": "500"
      },
      {
        "FieldName": "people",
        "Condition": "lte",
        "Value": "2500"
      }
    ]
  }
]"},
    }
    req, err := http.NewRequest("POST", fullUrl, strings.NewReader(formData.Encode()))
    if err != nil {
        panic(err)
    }

    // Set headers
    req.Header.Set("ccode", "request_user_007")
    req.Header.Set("key", "dd83e51f-6d0a-4510-a885-6b54e5881961")
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }

    fmt.Println("Status:", resp.Status)
    fmt.Println("Response:", string(body))
}
// Add to Cargo.toml dependencies:
// [dependencies]
// reqwest = { version = "0.11", features = ["json", "multipart"] }
// tokio = { version = "1.0", features = ["full"] }
// serde = { version = "1.0", features = ["derive"] }
// serde_json = "1.0"

use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let client = Client::new();

    // Build URL
    let mut url = "https://api.geointellect.com/glayer/do_identify".to_string();

    // Build request
    let mut request = client.post(&url);

    // Add headers
    request = request.header("ccode", "request_user_007");
    request = request.header("key", "dd83e51f-6d0a-4510-a885-6b54e5881961");

    // Add URL encoded data
    let mut form = HashMap::new();
    form.insert("xlon", "37.517023");
    form.insert("ylat", "55.662627");
    form.insert("zoom", "14");
    form.insert("aswgs", "true");
    form.insert("gilayers", "[
  {
    "Id": 101,
    "Filter": [
      {
        "FieldName": "people",
        "Condition": "gte",
        "Value": "500"
      },
      {
        "FieldName": "people",
        "Condition": "lte",
        "Value": "2500"
      }
    ]
  }
]");
    request = request.form(&form);

    // Send request
    let response = request.send().await?;

    // Check status
    if !response.status().is_success() {
        eprintln!("Request failed with status: {}", response.status());
        return Ok(());
    }

    // Read response
    let body = response.text().await?;

    println!("Response: {}", body);
    
    // If you want to parse as JSON:
    // let json_response: serde_json::Value = serde_json::from_str(&body)?;
    // println!("Parsed JSON: {:?}", json_response);

    Ok(())
}
Примеры ответов
{
  "status": "success",
  "success": true,
  "message": "",
  "details": "",
  "results": [
    {
      "id": 101,
      "uid": "00000000-0000-0000-0000-000000000000",
      "name": "Домохозяйства и население по домам (ЦПИ)(демо)",
      "editable": false,
      "schema": null,
      "count": 1,
      "features": [
        {
          "geometry": {
            "coordinates": [
              37.51704772307813,
              55.66254893622015
            ],
            "type": "Point"
          },
          "properties": {
            "id": 385194,
            "Walls": "монолитный железобетон",
            "Entrance": 4,
            "lift": 4,
            "type": " ",
            "name": " ",
            "adres": "Москва, Ленинский пр., 107, корп.3",
            "people": 1155,
            "Household": 383,
            "Sastr": " ",
            "District": "Юго-Западный административный округ",
            "city": null,
            "year": 2011,
            "Floors": 21,
            "state": "действующий"
          },
          "id": "385194",
          "type": "Feature"
        }
      ],
      "is_pay": false
    }
  ]
}