/poptools/income_poly

POST

Доход в полигоне

Рассчитывает доход семьи из двух работающих в указанном полигоне

Нюансы:

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

Headers

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

Body

URLENCODED
polygon
{"type":"Polygon","coordinates":[[[37.519426,55.658028],[37.520285,55.658633],[37.525992,55.66316],[37.526507,55.665072],[37.528481,55.665314],[37.530971,55.664394],[37.536249,55.664491],[37.540669,55.665096],[37.53758,55.656042],[37.528653,55.657059],[37.521572,55.657592],[37.519426,55.658028]]]}
Полигон в формате GeoJSON Polygon
Примеры запросов
curl -X POST \
  -L 'https://api.geointellect.com/poptools/income_poly' \
  -H 'ccode: request_user_007' \
  -H 'key: dd83e51f-6d0a-4510-a885-6b54e5881961' \
  --data-urlencode 'polygon=%7b%22type%22%3a%22Polygon%22%2c%22coordinates%22%3a%5b%5b%5b37.519426%2c55.658028%5d%2c%5b37.520285%2c55.658633%5d%2c%5b37.525992%2c55.66316%5d%2c%5b37.526507%2c55.665072%5d%2c%5b37.528481%2c55.665314%5d%2c%5b37.530971%2c55.664394%5d%2c%5b37.536249%2c55.664491%5d%2c%5b37.540669%2c55.665096%5d%2c%5b37.53758%2c55.656042%5d%2c%5b37.528653%2c55.657059%5d%2c%5b37.521572%2c55.657592%5d%2c%5b37.519426%2c55.658028%5d%5d%5d%7d'  \
  -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/income_poly");
        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("polygon", @"
                             {
                               ""type"": ""Polygon"",
                               ""coordinates"": [
                                 [
                                   [
                                     37.519426,
                                     55.658028
                                   ],
                                   [
                                     37.520285,
                                     55.658633
                                   ],
                                   [
                                     37.525992,
                                     55.66316
                                   ],
                                   [
                                     37.526507,
                                     55.665072
                                   ],
                                   [
                                     37.528481,
                                     55.665314
                                   ],
                                   [
                                     37.530971,
                                     55.664394
                                   ],
                                   [
                                     37.536249,
                                     55.664491
                                   ],
                                   [
                                     37.540669,
                                     55.665096
                                   ],
                                   [
                                     37.53758,
                                     55.656042
                                   ],
                                   [
                                     37.528653,
                                     55.657059
                                   ],
                                   [
                                     37.521572,
                                     55.657592
                                   ],
                                   [
                                     37.519426,
                                     55.658028
                                   ]
                                 ]
                               ]
                             }"));
        
        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/income_poly"

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

# URL-encoded form data
data = {
    'polygon': '{"type":"Polygon","coordinates":[[[37.519426,55.658028],[37.520285,55.658633],[37.525992,55.66316],[37.526507,55.665072],[37.528481,55.665314],[37.530971,55.664394],[37.536249,55.664491],[37.540669,55.665096],[37.53758,55.656042],[37.528653,55.657059],[37.521572,55.657592],[37.519426,55.658028]]]}',
}

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({
    'polygon': '{"type":"Polygon","coordinates":[[[37.519426,55.658028],[37.520285,55.658633],[37.525992,55.66316],[37.526507,55.665072],[37.528481,55.665314],[37.530971,55.664394],[37.536249,55.664491],[37.540669,55.665096],[37.53758,55.656042],[37.528653,55.657059],[37.521572,55.657592],[37.519426,55.658028]]]}',
  }),
};

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

    formData := url.Values{
        "polygon": {"{"type":"Polygon","coordinates":[[[37.519426,55.658028],[37.520285,55.658633],[37.525992,55.66316],[37.526507,55.665072],[37.528481,55.665314],[37.530971,55.664394],[37.536249,55.664491],[37.540669,55.665096],[37.53758,55.656042],[37.528653,55.657059],[37.521572,55.657592],[37.519426,55.658028]]]}"},
    }
    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/income_poly".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("polygon", "{"type":"Polygon","coordinates":[[[37.519426,55.658028],[37.520285,55.658633],[37.525992,55.66316],[37.526507,55.665072],[37.528481,55.665314],[37.530971,55.664394],[37.536249,55.664491],[37.540669,55.665096],[37.53758,55.656042],[37.528653,55.657059],[37.521572,55.657592],[37.519426,55.658028]]]}");
    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": {
    "Parameter": "POP_IN_ZONE",
    "Value": 6419,
    "TextRepresentation": "peop.",
    "Units": "peop.",
    "data": "{\"type\":\"pop\"}"
  }
}