@svizzle/geo/topojson

Methods

(inner) - Object -> Any -> (options) → {function}

Source:
Since:
  • 0.8.0

Return a function expecting a value for the provided property in the object corresponding to the provided object id and that returns a function expecting the topojson to be filtered.

Example
> filterGeometriesBy = makeFilterTopoBy({objId: 'NUTS', propKey: 'NUTS_ID'})
> topoRO = filterGeometriesBy('RO')
>
> topoRO(NUTS_RG_03M_2003_4326_LEVL_0)
// see `svizzle/atlas/data/dist/topojson/NUTS_RG_03M_2003_4326_LEVL_0_RO.js`
>
> topoRO(NUTS_RG_03M_2006_4326_LEVL_0)
// see `svizzle/atlas/data/dist/topojson/NUTS_RG_03M_2006_4326_LEVL_0_RO.js`
Parameters:
Name Type Description
options object
Properties
Name Type Description
objId string

a key of topojson.objects

propKey string

a key of topojson.objects[objId].geometries[i].properties

Returns:
  • Any -> (Object -> Object)
Type
function

(static) topoToGeo(topojson, string) → {object}

Source:
Since:
  • 0.7.0

Convert a topojson to a geojson. Ported from /choropleth v0.4.0 to /geo v0.7.0, but without truncating digits.

Example
> const topojson = {
	'type': 'Topology',
	'transform': {
		'scale': [0.00001,0.00001],
		'translate': [-63.15364,-21.38731]
	},
	'objects': {
		'NUTS': {
			'type': 'GeometryCollection',
			'geometries': [
				{
					'type': 'Polygon',
					'arcs': [...],
					'id': 'BE',
					'properties': {...}
				}
			]
		}
	},
	'arcs': [[[6569909,7247636], [1369,-1901], ...]
}
> topoToGeo(topojson, 'NUTS')
{
	'type': 'FeatureCollection',
	'features': [
		{
			'type': 'Feature',
			'id': 'BE',
			'properties': {...},
			'geometry': {
				'type': 'Polygon',
				'coordinates': [
					[[6.3163...,50.4967...],
					...
				]
			}
		}
	]
}
Parameters:
Name Type Description
topojson object

the topojson to be converted to geojson

string id

the id of the object to convert

Returns:

geojson

Type
object