Convert Figma logo to code with AI

iTowns logoitowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data

1,157
308
1,157
236

Top Related Projects

106,888

JavaScript 3D Library.

13,390

WebGL2 powered visualization framework

13,852

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

OpenLayers

43,292

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

Quick Overview

iTowns is an open-source 3D geospatial data visualization framework developed by the French National Institute of Geographic and Forest Information (IGN). It is designed to visualize and interact with large-scale 3D geographic data, such as terrain, buildings, and other geospatial features, in a web browser.

Pros

  • Powerful Visualization Capabilities: iTowns provides advanced 3D rendering capabilities, allowing users to visualize and interact with complex geospatial data in a web-based environment.
  • Flexible and Extensible: The framework is designed to be highly customizable and extensible, enabling developers to integrate their own data sources and create custom applications.
  • Cross-Platform Compatibility: iTowns is a web-based solution, making it accessible across various platforms and devices, including desktop and mobile.
  • Active Community and Documentation: The project has an active community of contributors and a comprehensive documentation that helps developers get started and extend the framework.

Cons

  • Steep Learning Curve: Mastering iTowns may require a significant investment of time and effort, especially for developers who are new to 3D geospatial visualization.
  • Performance Limitations: Rendering large-scale 3D data can be resource-intensive, and developers may need to optimize their applications to ensure smooth performance, especially on lower-end devices.
  • Limited Offline Capabilities: While iTowns can be used offline, the framework is primarily designed for web-based applications, which may limit its usefulness in certain scenarios where offline access is required.
  • Dependency on WebGL: iTowns relies on WebGL, which may not be supported by all browsers or devices, potentially limiting its reach.

Code Examples

Here are a few code examples demonstrating the usage of iTowns:

  1. Initializing the Viewer:
import * as itowns from 'itowns';

const viewer = new itowns.Viewer({
  div: 'viewerDiv',
  camera: {
    position: {
      x: 2.0,
      y: -0.5,
      z: 1.0
    },
    target: {
      x: 0.0,
      y: 0.0,
      z: 0.0
    }
  }
});

This code initializes an iTowns viewer and sets the initial camera position and target.

  1. Adding a Terrain Layer:
const elevationLayer = new itowns.ElevationLayer('elevation', {
  source: {
    url: 'https://example.com/elevation.json',
    format: 'json'
  }
});

viewer.addLayer(elevationLayer);

This code adds an elevation layer to the iTowns viewer, using a custom data source.

  1. Adding a Building Layer:
const buildingLayer = new itowns.BuildingLayer('buildings', {
  source: {
    url: 'https://example.com/buildings.json',
    format: 'json'
  }
});

viewer.addLayer(buildingLayer);

This code adds a building layer to the iTowns viewer, using a custom data source.

  1. Interacting with the Viewer:
viewer.controls.setTilt(45);
viewer.controls.setHeading(30);
viewer.controls.setZoom(2000);

This code demonstrates how to interact with the iTowns viewer by setting the tilt, heading, and zoom level of the camera.

Getting Started

To get started with iTowns, follow these steps:

  1. Install the iTowns package using npm or yarn:
npm install itowns
  1. Import the necessary modules and create a new iTowns viewer:
import * as itowns from 'itowns';

const viewer = new itowns.Viewer({
  div: 'viewerDiv',
  camera: {
    position: {
      x: 2.0,
      y: -0.5,
      z: 1.0
    },
    target: {
      x: 0.0,
      y: 0.0,
      z: 0.0
    }

Competitor Comparisons

106,888

JavaScript 3D Library.

Pros of three.js

  • More versatile and general-purpose 3D library
  • Larger community and ecosystem with extensive documentation
  • Supports a wider range of 3D applications beyond geospatial

Cons of three.js

  • Lacks built-in geospatial features and optimizations
  • Steeper learning curve for geospatial-specific applications
  • May require additional libraries for advanced geospatial functionality

Code Comparison

three.js:

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

iTowns:

const viewerDiv = document.getElementById('viewerDiv');
const placement = { heading: 0, range: 25000, tilt: 40 };
const view = new itowns.GlobeView(viewerDiv, placement);
const colorLayer = new itowns.ColorLayer('Ortho', { source: new itowns.WMTSSource({ ... }) });
view.addLayer(colorLayer);

The code snippets demonstrate the different focus of each library. three.js provides a more general 3D scene setup, while iTowns offers geospatial-specific functionality out of the box, such as globe views and geospatial data layers.

13,390

WebGL2 powered visualization framework

Pros of deck.gl

  • Extensive ecosystem with numerous layers and extensions
  • High-performance rendering for large datasets
  • Strong integration with React and other web frameworks

Cons of deck.gl

  • Steeper learning curve for beginners
  • Less focused on geospatial data compared to iTowns

Code Comparison

deck.gl:

import {Deck} from '@deck.gl/core';
import {GeoJsonLayer} from '@deck.gl/layers';

new Deck({
  layers: [new GeoJsonLayer({id: 'geojson', data: GEOJSON_DATA})]
});

iTowns:

import * as itowns from 'itowns';

const viewerDiv = document.getElementById('viewerDiv');
const view = new itowns.GlobeView(viewerDiv, position);
itowns.Fetcher.json('path/to/data.geojson').then((geojson) => {
  const layer = new itowns.ColorLayer('geojson', { source: geojson });
  view.addLayer(layer);
});

Both libraries offer powerful capabilities for visualizing geospatial data, but deck.gl provides a more flexible and performance-oriented approach for general data visualization, while iTowns specializes in 3D geospatial rendering. deck.gl's modular architecture allows for easier customization, but iTowns may be more intuitive for users primarily working with geographic data.

13,852

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:

Pros of Cesium

  • More mature and widely adopted, with a larger community and ecosystem
  • Extensive documentation and learning resources available
  • Supports a broader range of data formats and sources

Cons of Cesium

  • Steeper learning curve due to its comprehensive feature set
  • Larger file size and potentially higher resource consumption
  • Some advanced features require a paid license

Code Comparison

Cesium

const viewer = new Cesium.Viewer('cesiumContainer');
const position = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
const entity = viewer.entities.add({
  position: position,
  point: { pixelSize: 10, color: Cesium.Color.RED }
});
viewer.zoomTo(entity);

iTowns

const viewerDiv = document.getElementById('viewerDiv');
const view = new itowns.GlobeView(viewerDiv);
const position = new itowns.Coordinates('EPSG:4326', -75.59777, 40.03883);
const geometry = new itowns.THREE.SphereGeometry(500, 32, 32);
const material = new itowns.THREE.MeshBasicMaterial({ color: 0xff0000 });
view.scene.add(new itowns.THREE.Mesh(geometry, material).position.copy(position.as(view.referenceCrs)));

Both libraries offer 3D globe visualization capabilities, but Cesium provides a more comprehensive set of features out-of-the-box, while iTowns offers greater flexibility for customization using Three.js. Cesium's API is generally more intuitive for geospatial operations, while iTowns may be more familiar to developers with Three.js experience.

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

Pros of Mapbox GL JS

  • More extensive documentation and community support
  • Better performance for large datasets and complex visualizations
  • Wider range of built-in features and customization options

Cons of Mapbox GL JS

  • Requires a Mapbox account and API key for full functionality
  • Less focus on 3D terrain and globe visualizations
  • Steeper learning curve for beginners

Code Comparison

iTowns example:

const viewerDiv = document.getElementById('viewerDiv');
const view = new itowns.GlobeView(viewerDiv, position);
const colorLayer = new itowns.ColorLayer('OPENSM', {
    source: new itowns.TMSSource({url: 'http://...'}),
});
view.addLayer(colorLayer);

Mapbox GL JS example:

mapboxgl.accessToken = 'YOUR_ACCESS_TOKEN';
const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11',
    center: [-74.5, 40],
    zoom: 9
});

Both libraries offer powerful mapping capabilities, but iTowns focuses more on 3D visualizations and globe views, while Mapbox GL JS excels in 2D mapping with extensive customization options. iTowns is open-source and doesn't require an API key, making it more accessible for some projects. Mapbox GL JS, however, offers better performance and a wider range of features, but requires an account and API key for full functionality.

OpenLayers

Pros of OpenLayers

  • More mature and widely adopted, with a larger community and ecosystem
  • Supports a broader range of data formats and map providers
  • Better documentation and extensive examples

Cons of OpenLayers

  • Larger file size and potentially slower performance for complex applications
  • Steeper learning curve due to its extensive feature set
  • Less focus on 3D capabilities compared to iTowns

Code Comparison

iTowns example:

const viewerDiv = document.getElementById('viewerDiv');
const view = new itowns.GlobeView(viewerDiv, position);
const colorLayer = new itowns.ColorLayer('OPENSM', {
    source: new itowns.TMSSource({url: 'https://.../{z}/{x}/{y}.png'}),
});
view.addLayer(colorLayer);

OpenLayers example:

const map = new ol.Map({
  target: 'map',
  layers: [
    new ol.layer.Tile({source: new ol.source.OSM()})
  ],
  view: new ol.View({center: [0, 0], zoom: 2})
});

Both libraries offer powerful mapping capabilities, but iTowns specializes in 3D visualizations, while OpenLayers excels in traditional 2D mapping with a wider range of features and data sources.

43,292

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

Pros of Leaflet

  • Lightweight and mobile-friendly, with a smaller file size
  • Extensive plugin ecosystem for added functionality
  • Simpler API and easier learning curve for basic 2D mapping

Cons of Leaflet

  • Limited 3D capabilities out of the box
  • Less suitable for complex geospatial data visualization
  • Fewer built-in features for advanced GIS operations

Code Comparison

Leaflet (2D map initialization):

var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: 'Β© OpenStreetMap contributors'
}).addTo(map);

iTowns (3D globe initialization):

var viewerDiv = document.getElementById('viewerDiv');
var placement = { coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712), range: 25e6 };
var view = new itowns.GlobeView(viewerDiv, placement);
var colorLayer = new itowns.ColorLayer('OPENSM', { source: new itowns.TMSSource({ url: 'http://c.tile.stamen.com/watercolor/${z}/${x}/${y}.jpg' }) });
view.addLayer(colorLayer);

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

iTowns

iTowns

Coverage Status example branch parameter DeepScan grade Discord

What is it?

iTowns is a Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data.

It can connect to WMS/WMTS/TMS servers including elevation data and load many different data formats (3dTiles, GeoJSON, Vector Tiles, GPX and much more). A complete list of features and supported data formats is available on the wiki.

It officially targets the last two major versions of both Firefox, Safari and Chromium-based browsers (Chrome, Edge, ...) at the date of each release. Older browsers supporting WebGL 2.0 may work but we do not offer support.

iTowns screenshot

Documentation and examples

The official documentation is available here. It contains tutorials to help you start using iTowns, and an API reference. You can find more informations on its contribution here.

Official examples can be viewed here. Some examples available:

iTowns examples

How to run it locally?

Clone the repo and then run:

npm install
npm start

Try out the examples at http://localhost:8080/examples

How to use it in your project?

You can use it through npm (the preferred way) or download a bundle from our github release page.

With npm

In your project:

To use all iTowns features, install itowns package :

npm install --save itowns
import { Coordinates } from 'itowns';

const coordinates = new Coordinates('EPSG:4326', 88., 50.3, 120.3);

// change projection system to pseudo mercator
coordinates.as('EPSG:3857');

To import Widget features

import { Navigation } from 'itowns/widgets';

const viewerDiv = document.getElementById('viewerDiv');

// Create a GlobeView
const view = new itowns.GlobeView(viewerDiv);

// Add navigation widget
const navigation = new Navigation(view, {
    position: 'bottom-right',
    translate: { y: -40 },
});

iTowns is currently moving to a monorepo organization and to a segmentation in sub-modules, allowing to import only some of itowns functionalities. Current itowns sub-modules are:

This package contains the ES5-compatible sources of iTowns, up to date with the latest release.

If you're using a module bundler (like wepback), you can directly write require('itowns') in your code.

Alternatively, we provide a bundle you can directly include in your html files that exposes itowns in window:

<script src="node_modules/itowns/dist/itowns.js"></script>

/!\ Please note that this bundle also contains the dependencies.

From a release bundle

See our release page. Note that there isn't a lot of support for older version of iTowns, we highly recommend to use the last release everytime.

Try modifications before they are released

If you want to try some features or bug fixes that are planned for the next release, we provide a @next version of itowns. You can install it as such :

npm install --save itowns@next

To switch back to the version to date with the latest release, you need to run :

npm install --save itowns@latest

Contributing

If you are interested in contributing to iTowns, please read the CONTRIBUTING guide and the CODING guide.

iTowns has been redesigned from this early version.

Licence

iTowns is dual-licenced under Cecill-B V1.0 and MIT. Incorporated libraries are published under their original licences.

See LICENSE.md for more information.

Maintainers

iTowns is an original work from French IGN, MATIS research laboratory. It has been funded through various research programs involving the French National Research Agency, Cap Digital, UPMC, Mines ParisTec, CNRS, LCPC and maintained by several organizations along the years (IGN, Oslandia, AtolCD, CIRIL Group). It has also received contributions from people listed here.

iTowns is currently maintained by IGN and CIRIL Group.

Contributions in any forms and new contributors and maintainers are welcome. Get in touch with us if you are interested :)

The governance of the project is open and explicited here.

IGN CIRIL Group

NPM DownloadsLast 30 Days