/poptools/pop_radius

POST

Население в радиусе

Рассчитывает население в радиусе от указанной точки

Нюансы:

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

Headers

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

Body

URLENCODED
xlon
37.54765
Долгота (в десятичных градусах)
ylat
55.66535
Широта (в десятичных градусах)
size
1000
Размер радиуса в метрах
asfeature
true
По-умолчанию = false, Если поставить true, то результат будет в формате GeoJSON Feature
aswgs
true
По-умолчанию = true, Если поставить false, то координаты вернутся в метрах (EPSG:3857). Работает только если `asfeature` = true
Примеры запросов
curl -X POST \
  -L 'https://api.geointellect.com/poptools/pop_radius' \
  -H 'ccode: request_user_007' \
  -H 'key: dd83e51f-6d0a-4510-a885-6b54e5881961' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'xlon=37.54765' \
  --data-urlencode 'ylat=55.66535' \
  --data-urlencode 'size=1000' \
  --data-urlencode 'asfeature=true' \
  --data-urlencode 'aswgs=true'  \
  -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/poptools/pop_radius");
        request.Headers.Add("ccode", "request_user_007");
        request.Headers.Add("key", "dd83e51f-6d0a-4510-a885-6b54e5881961");
        request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
        
        var collection = new List<KeyValuePair<string, string>>();
        collection.Add(new("xlon", "37.54765"));
        collection.Add(new("ylat", "55.66535"));
        collection.Add(new("size", "1000"));
        collection.Add(new("asfeature", "true"));
        collection.Add(new("aswgs", "true"));
        
        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/poptools/pop_radius"

headers = {
    'ccode': 'request_user_007',
    'key': 'dd83e51f-6d0a-4510-a885-6b54e5881961',
    'Content-Type': 'application/x-www-form-urlencoded',
}

# URL-encoded form data
data = {
    'xlon': '37.54765',
    'ylat': '55.66535',
    'size': '1000',
    'asfeature': 'true',
    'aswgs': 'true',
}

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',
  'Content-Type': 'application/x-www-form-urlencoded',
};

const options = {
  method: 'POST',
  headers: headers,
  body: new URLSearchParams({
    'xlon': '37.54765',
    'ylat': '55.66535',
    'size': '1000',
    'asfeature': 'true',
    'aswgs': 'true',
  }),
};

fetch('https://api.geointellect.com/poptools/pop_radius', 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/poptools/pop_radius"
    fullUrl := baseUrl

    formData := url.Values{
        "xlon": {"37.54765"},
        "ylat": {"55.66535"},
        "size": {"1000"},
        "asfeature": {"true"},
        "aswgs": {"true"},
    }
    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/poptools/pop_radius".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");
    request = request.header("Content-Type", "application/x-www-form-urlencoded");

    // Add URL encoded data
    let mut form = HashMap::new();
    form.insert("xlon", "37.54765");
    form.insert("ylat", "55.66535");
    form.insert("size", "1000");
    form.insert("asfeature", "true");
    form.insert("aswgs", "true");
    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": null,
  "results": {
    "geometry": {
      "coordinates": [
        [
          [
            37.563576854895445,
            55.66535
          ],
          [
            37.56351624840412,
            55.66613292552651
          ],
          [
            37.563334890182134,
            55.666909877032346
          ],
          [
            37.56303416047507,
            55.66767494197719
          ],
          [
            37.56261634801758,
            55.66842229861986
          ],
          [
            37.56208463261474,
            55.669146260298895
          ],
          [
            37.56144306094184,
            55.66984131867587
          ],
          [
            37.56069651574669,
            55.6705021856132
          ],
          [
            37.55985067868902,
            55.67112383336908
          ],
          [
            37.55891198709955,
            55.671701532805365
          ],
          [
            37.55788758498807,
            55.67223088931901
          ],
          [
            37.55678526867321,
            55.67270787622583
          ],
          [
            37.555613427447724,
            55.67312886534394
          ],
          [
            37.55438097973091,
            55.6734906545465
          ],
          [
            37.553097305194065,
            55.67379049207534
          ],
          [
            37.55177217337553,
            55.674026097432716
          ],
          [
            37.55041566932856,
            55.67419567869324
          ],
          [
            37.54903811686805,
            55.67429794610584
          ],
          [
            37.54765,
            55.67433212188337
          ],
          [
            37.546261883131955,
            55.67429794610584
          ],
          [
            37.544884330671444,
            55.67419567869324
          ],
          [
            37.54352782662448,
            55.674026097432716
          ],
          [
            37.54220269480594,
            55.67379049207534
          ],
          [
            37.540919020269094,
            55.6734906545465
          ],
          [
            37.539686572552284,
            55.67312886534394
          ],
          [
            37.5385147313268,
            55.67270787622583
          ],
          [
            37.537412415011936,
            55.67223088931901
          ],
          [
            37.53638801290046,
            55.671701532805365
          ],
          [
            37.53544932131099,
            55.67112383336908
          ],
          [
            37.5346034842533,
            55.6705021856132
          ],
          [
            37.53385693905816,
            55.66984131867587
          ],
          [
            37.53321536738526,
            55.669146260298895
          ],
          [
            37.53268365198243,
            55.66842229861986
          ],
          [
            37.53226583952494,
            55.66767494197719
          ],
          [
            37.53196510981787,
            55.666909877032346
          ],
          [
            37.53178375159589,
            55.66613292552651
          ],
          [
            37.531723145104564,
            55.66535
          ],
          [
            37.53178375159589,
            55.66456705881027
          ],
          [
            37.53196510981787,
            55.66379006079075
          ],
          [
            37.53226583952494,
            55.663024919895
          ],
          [
            37.53268365198243,
            55.66227746017197
          ],
          [
            37.53321536738526,
            55.661553371415145
          ],
          [
            37.53385693905816,
            55.66085816582416
          ],
          [
            37.5346034842533,
            55.660197136009614
          ],
          [
            37.53544932131099,
            55.659575314662256
          ],
          [
            37.53638801290046,
            55.65899743619471
          ],
          [
            37.537412415011936,
            55.6584679006498
          ],
          [
            37.5385147313268,
            55.65799074015151
          ],
          [
            37.539686572552284,
            55.65756958815617
          ],
          [
            37.540919020269094,
            55.65720765173961
          ],
          [
            37.54220269480594,
            55.656907687132986
          ],
          [
            37.54352782662448,
            55.656671978695236
          ],
          [
            37.544884330671444,
            55.656502321483835
          ],
          [
            37.546261883131955,
            55.65640000755754
          ],
          [
            37.54765,
            55.656365816116804
          ],
          [
            37.54903811686805,
            55.65640000755754
          ],
          [
            37.55041566932856,
            55.656502321483835
          ],
          [
            37.55177217337553,
            55.656671978695236
          ],
          [
            37.553097305194065,
            55.656907687132986
          ],
          [
            37.55438097973091,
            55.65720765173961
          ],
          [
            37.555613427447724,
            55.65756958815617
          ],
          [
            37.55678526867321,
            55.65799074015151
          ],
          [
            37.55788758498807,
            55.6584679006498
          ],
          [
            37.55891198709955,
            55.65899743619471
          ],
          [
            37.55985067868902,
            55.659575314662256
          ],
          [
            37.56069651574669,
            55.660197136009614
          ],
          [
            37.56144306094184,
            55.66085816582416
          ],
          [
            37.56208463261474,
            55.661553371415145
          ],
          [
            37.56261634801758,
            55.66227746017197
          ],
          [
            37.56303416047507,
            55.663024919895
          ],
          [
            37.563334890182134,
            55.66379006079075
          ],
          [
            37.56351624840412,
            55.66456705881027
          ],
          [
            37.563576854895445,
            55.66535
          ]
        ]
      ],
      "type": "Polygon"
    },
    "properties": {
      "pop": 33546
    },
    "id": "0",
    "type": "Feature"
  }
}
{
  "status": "success",
  "success": true,
  "message": "",
  "details": "",
  "results": {
    "Parameter": "POP_IN_ZONE",
    "Value": 33546,
    "TextRepresentation": "peop.",
    "Units": "peop.",
    "data": "{\"type\":\"pop\"}"
  }
}