Skip to content

Cómo construir un mapa de co-ubicación

El motor GIS de PointSav expone una API de tiles y un punto de conexión de clústeres que puedes integrar en cualquier aplicación MapLibre GL. Esta guía cubre la autenticación con la API GIS, la obtención de la capa GeoJSON de clústeres y la renderización de marcadores de clústeres con color por nivel en un lienzo MapLibre.

Para la arquitectura del motor GIS, consulta pointsav-gis-engine. Para el sistema de puntuación de co-ubicación que produce los datos de clústeres, consulta el sistema de clasificación de co-ubicación.

Antes de empezar

Necesitas:

  • Una clave de API GIS proporcionada por el administrador de la plataforma
  • Un proyecto web con MapLibre GL JS v3 o posterior cargado
  • La URL base de tu despliegue GIS (por ejemplo, https://gis.example.com)

Paso 1: Intercambia tu clave de API por un token de sesión

El punto de conexión de clústeres requiere un token bearer de corta duración. Intercambia tu clave de API en el punto de autenticación:

curl -X POST https://<tu-host-gis>/api/auth/token \
  -H "Content-Type: application/json" \
  -d '{"api_key": "<tu-clave-de-api>"}' \
  -o token.json

TOKEN=$(jq -r .access_token token.json)

Los tokens vencen después de una hora. Para renovar, repite el intercambio. Si tu aplicación corre en un navegador, realiza este intercambio en el lado del servidor y actúa como proxy del punto de conexión de clústeres para evitar exponer la clave de API a los clientes.

Paso 2: Obtén el GeoJSON de clústeres

Descarga la capa de clústeres para los países que deseas mostrar:

curl -fsSL \
  -H "Authorization: Bearer $TOKEN" \
  "https://<tu-host-gis>/api/v1/clusters?country=US" \
  -o clusters.geojson

La respuesta es un FeatureCollection GeoJSON. Cada característica tiene una propiedad tier (T1, T2 o T3) y un cluster_id. Los parámetros de consulta opcionales son country (ISO 3166-1 alpha-2), min_tier (T1 o T2) y bbox (oeste,sur,este,norte).

Paso 3: Inicializa el mapa MapLibre

import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

const map = new maplibregl.Map({
  container: 'map',            // id del elemento DOM donde montar el mapa
  style: '<url-del-estilo-base>',
  center: [-98.5, 39.5],      // lon, lat
  zoom: 4,
});

Reemplaza style con la URL del mapa base de tu despliegue. El elemento contenedor del mapa debe tener una altura CSS explícita; un contenedor sin dimensiones se renderiza con altura cero.

Paso 4: Agrega la fuente GeoJSON de clústeres

map.on('load', () => {
  map.addSource('clusters', {
    type: 'geojson',
    data: clusters,          // el objeto FeatureCollection ya analizado
  });

Si sirves el GeoJSON directamente desde el punto de conexión de la API en un contexto de navegador, pasa la URL del punto de conexión como data y proporciona el token bearer mediante una función de retorno de llamada transformRequest en las opciones del constructor Map.

Paso 5: Agrega la capa de círculos con color por nivel

  map.addLayer({
    id: 'cluster-circles',
    type: 'circle',
    source: 'clusters',
    paint: {
      'circle-color': [
        'match', ['get', 'tier'],
        'T1', '#2563eb',
        'T2', '#7c3aed',
        /* T3 */ '#6b7280',
      ],
      'circle-radius': [
        'match', ['get', 'tier'],
        'T1', 12,
        'T2', 9,
        /* T3 */ 6,
      ],
      'circle-opacity': 0.85,
    },
  });
});

Los clústeres T1 (centros regionales, mayor composición de anclas) se renderizan más grandes y en azul. Los clústeres T2 (centros de distrito) en púrpura. Los clústeres T3 (pares locales) en gris y con el tamaño más pequeño. Ajusta los colores y radios para que coincidan con el lenguaje visual de tu aplicación.

Véase también

  • pointsav-gis-engine — arquitectura del motor GIS y superficies de API disponibles
  • metodología de co-ubicación — cómo se puntúan los niveles de los clústeres
  • metodología de captación O-D — cómo se definen las áreas comerciales
  • federate-archives-via-content-mounts — monta datos de inteligencia de ubicación en una segunda instancia
Important Information

Important Information

Corporate structure. PointSav Digital Systems ("PointSav") is a trade name of Woodfine Capital Projects Inc. ("Woodfine"). PointSav does not itself offer, sell, or solicit any security. Any securities offering associated with Woodfine's real-property direct-hold solutions is made exclusively by Woodfine, and only by means of the applicable Private Placement Memorandum.

No investment advice. This wiki's content is provided for engineering, operational, research, and development purposes. Nothing on this wiki constitutes investment advice or a solicitation to invest in any Woodfine partnership or direct-hold solution.

Intellectual property. The PointSav name, trade name, wordmark, and marks, together with all current and future PointSav- and Totebox-branded products, services, and offerings — and the software, source code, documentation, design system, and all related materials — are proprietary to Woodfine and its affiliates, except for components identified as open source. No rights are granted except as expressly set out in a written license or agreement. See TRADEMARK.md in this repository for the full trademark notice.

Open source components. Portions of the platform are made available under permissive open-source licenses identified in the accompanying repository. Use of those components is governed by their respective license terms.

No warranty; informational use. Content on this wiki is provided for general informational purposes only and does not constitute a representation, warranty, or commitment with respect to product functionality, availability, pricing, or roadmap. Some articles describe planned or intended features, capabilities, and milestones — language such as "planned," "intended," "targeted," "may," and "expected" marks this forward-looking content, which is subject to change and does not constitute a commitment regarding future performance.

Confidentiality. Where an article describes an operational or deployment detail that is not intended for public disclosure, that article is not published on this wiki. Content here is general-purpose engineering documentation, not customer-specific configuration.

Jurisdiction. Woodfine Capital Projects Inc. is organized in British Columbia, Canada. References to the Sovereign Data Foundation on this wiki describe a planned or intended initiative only, not a current equity holder or active governance body.

Changes to this notice. PointSav may update this notice from time to time; the version posted on this page governs.

Not a filing system. This wiki is not a securities filing system, an electronic disclosure repository, or a substitute for SEDAR+ or any other regulatory filing system. Formal securities filings are made through the applicable regulatory filing system, not through this wiki.

Full disclaimer. This notice supplements, and does not replace, the full Disclaimers article. In the event of any conflict, the full Disclaimers article governs.

Read the full disclaimer →