topo_client library

Manipulate TopoJSON, such as to merge shapes, and convert it back to GeoJSON.

The topo_client package provides tools for manipulating TopoJSON, such as to merge shapes or quantize coordinates, and for converting back to GeoJSON (using feature) for rendering with standard tools such as GeoPath. For example, bl.ocks.org/3783604:

import 'dart:convert';

import 'package:d4_geo/d4_geo.dart';
import 'package:http/http.dart' as http;

void main() async {
  var path = GeoPath();

  String url = "https://d3js.org/us-10m.v1.json";
  final response = await http.get(Uri.parse(url));

  path(jsonDecode(response.body));
}

Functions

bbox(Map<String?, dynamic> topology) List<num>
Returns the computed bounding box of the specified topology.
feature(Map<String?, dynamic> topology, Map<String?, dynamic> object) Map<String?, dynamic>
Returns the GeoJSON Feature or FeatureCollection for the specified object in the given topology.
merge(Map<String?, dynamic> topology, List<Map<String?, dynamic>> objects) Map<String?, dynamic>
Returns the GeoJSON MultiPolygon geometry object representing the union for the specified array of Polygon and MultiPolygon objects in the given topology.
mergeArcs(Map<String?, dynamic> topology, List<Map<String?, dynamic>> objects) Map<String?, dynamic>
Equivalent to merge, but returns TopoJSON rather than GeoJSON.
mesh(Map<String?, dynamic> topology, [Map<String?, dynamic>? object, dynamic filter]) Map<String?, dynamic>
Returns the GeoJSON MultiLineString geometry object representing the mesh for the specified object in the given topology.
meshArcs(Map<String?, dynamic> topology, [Map<String?, dynamic>? object, bool filter(Map<String?, dynamic>, Map<String?, dynamic>)?]) Map<String?, dynamic>
Equivalent to mesh, but returns TopoJSON rather than GeoJSON.
neighbors(List<Map<String?, dynamic>> objects) List<List<int>>
Returns an array representing the set of neighboring objects for each object in the specified objects array.
pointTransform(Map<String?, List<num>>? transform) Transform
Returns a point transform function to remove delta-encoding and apply the transform.
quantize(Map<String?, dynamic> topology, Map<String?, List<num>> transform) Map<String?, dynamic>
Returns a shallow copy of the specified topology with quantized and delta-encoded arcs according to the specified transform object.
transform(Map<String?, dynamic> topology, num n) Map<String?, List<num>>
Returns a transform object computed using the bounding box of the topology.
untransformPoint(Map<String?, List<num>>? transform) Transform
Returns a point transform function to apply quantized delta-encoding and remove the transform.

Typedefs

Transform = List<Object?> Function(List<Object?> point, [int index])
Applies this transform function to the specified point, returning a new point with the transformed coordinates.