topojson 0.2.0 copy "topojson: ^0.2.0" to clipboard
topojson: ^0.2.0 copied to clipboard

A Dart port of topojson.

example/topojson_example.dart

import 'dart:convert';
import 'dart:io' as io;

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

void main() async {
  /// Testing topojson to geojson conversion;
  final resp = await http.get(
      Uri.parse('https://geoshape.ex.nii.ac.jp/jma/resource/AreaInformationCity_landslide/20210518/4220201.topojson'));
  final topoJson = jsonDecode(utf8.decode(resp.bodyBytes));

  final geoJson = jsonEncode(toGeoJson(topoJson));

  await io.File('4220201.geojson').writeAsString(geoJson);
}