Skip to content

Conversation

@mashazyu
Copy link
Contributor

@mashazyu mashazyu commented Nov 6, 2025

This is a proof of concept PR by request of @felixerdy

Type of Change

  • Dependency upgrade
  • Bug fix (non-breaking change)
  • Breaking change
    • e.g. a fixed bug or new feature that may break something else
  • New feature
  • Code quality improvements
    • e.g. refactoring, documentation, tests, tooling, ...

Implementation

This PR adds Martin tile server integration to enable serving vector tiles from PostGIS database views.

Here is how tile data looks like in kepler.gl

image

Key Changes

  1. Martin Tile Server Setup (docker-compose.yml)

    • Added Martin service running on port 3001 (host) to avoid conflicts with frontend dev server
    • Configured to connect to PostGIS database and automatically discover views/tables with geometry columns (SRID 4326)
    • Added health checks and proper service dependencies
  2. Analysis View (drizzle/0023_create_analysis_view.sql)

    • Created denormalized database view analysis_view that combines:
      • Measurement timestamps (createdAt)
      • Device information (boxId, tags)
      • Location geometry (PostGIS Point, SRID 4326)
      • Scalar columns for common phenomena (temperature, humidity, soil moisture, pressure, particulate matter, wind speed, light intensity, UV, sound levels, VOC, CO₂)
  3. Environment Configuration (app/utils/env.server.ts)

    • Added optional MARTIN_URL environment variable (defaults to http://localhost:3001)
  4. Documentation (MARTIN_SETUP.md)

    • Local setup guide

How It Works

  • Martin automatically discovers database views/tables with geometry columns that have SRID 4326
  • The analysis_view provides a denormalized structure optimized for data analysis and visualization
  • Vector tiles are served on-demand from the PostGIS database, enabling efficient map rendering

Checklist

  • I gave this pull request a meaningful title
  • My pull request is targeting the dev branch
  • I have added documentation to my code
  • I have deleted code that I have commented out

Additional Information

@mashazyu mashazyu requested a review from felixerdy November 6, 2025 14:01
@mashazyu mashazyu self-assigned this Nov 6, 2025
"when": 1761122113831,
"tag": "0022_odd_sugar_man",
"breakpoints": true
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I am not sure it needs to be commited

@mashazyu
Copy link
Contributor Author

@felixerdy

Per our conversation

  • I converted sensor data to columns. Downside - if new sensor type is added, we'd need to create and run a migration.
  • Api endpoint is not needed, I just added for testing purposes.

Next questions

  • if, when and how should data from the view be deleted? currently it's done via api call, but I assume this is not how it's meant to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants