forked from newsapps/django-boundaryservice
-
Notifications
You must be signed in to change notification settings - Fork 15
/
definition.example.py
87 lines (76 loc) · 3.82 KB
/
definition.example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from datetime import date
import boundaries
boundaries.register(
# The string to be used for the boundary set's slug. The slug will be "federal-electoral-districts".
'Federal electoral districts',
# (Optional) The path to the shapefile's directory relative to this file.
# If this definition file and the shapefile share the same directory, you
# can omit this parameter, or set it to the empty string.
file='',
# (Optional) The encoding of the shapefile's attributes. The default is
# "ascii", but many shapefiles are encoded as "iso-8859-1".
encoding='iso-8859-1',
# (Optional) Override the Spatial Reference System Identifier (SRID) of
# the shapefile.
srid=4269,
# The following Boundary Set fields will be made available via the API.
# The most recent date on which the data was updated.
last_updated=date(2011, 11, 28),
# The plural name of the boundary set, for display. By default, it will use
# the boundary set's slug.
name='Federal electoral districts',
# A generic singular name for a boundary in the set. If the boundary set's
# name ends in "s", this parameter is optional, as is the case here.
singular='Federal electoral district',
# (Optional) The geographic area covered by the boundary set, which is
# often a country, a region, a municipality, etc.
domain='Canada',
# (Optional) The entity responsible for publishing the data.
authority='Her Majesty the Queen in Right of Canada',
# (Optional) A URL to the source of the data.
source_url='http://data.gc.ca/data/en/dataset/48f10fb9-78a2-43a9-92ab-354c28d30674',
# (Optional) A URL to the licence under which the data is made available.
licence_url='http://data.gc.ca/eng/open-government-licence-canada',
# (Optional) The date from which the set's boundaries are in effect.
start_date=None,
# (Optional) The date until which the set's boundaries are in effect.
end_date=None,
# (Optional) Free-form text notes, often used to describe changes that were
# made to the original source data, e.g. deleted or merged features.
notes='',
# (Optional) Any additional metadata to include in API responses.
extra={'id': 'ocd-division/country:ca'},
# The following Boundary functions take a feature as an argument and return
# an appropriate value as described below.
#
# In this case, we use helper functions to access and clean attributes from
# the shapefile:
#
# * `attr` retrieves a feature's attribute without making changes.
# * `clean_attr` title-cases a string if it is all-caps, normalizes
# whitespace, and normalizes long dashes.
# * `dashed_attr` does the same as `clean_attr`, but replaces all hyphens
# with long dashes.
#
# If you want to write your own function, set for example `name_func=namer`
# and define a function that looks like:
#
# def namer(f):
# return f.get('FEDENAME')
# A function that returns a feature's name.
name_func=boundaries.clean_attr('FEDENAME'),
# (Optional) A function that returns a feature's identifier, which should
# be unique across the features in the shapefile and relatively stable
# across time: for example, a district number or a geographic code. By
# default, features have no identifiers.
id_func=boundaries.attr('FEDUID'),
# (Optional) A function that returns a feature's slug (the last part of its
# URL path). By default, it will use the feature's name.
slug_func=boundaries.attr('FEDUID'),
# (Optional) A function that returns whether a feature should be loaded. By
# default, all features are loaded.
is_valid_func=lambda feature: True,
# (Optional) A function that returns the Point at which to place a label
# for the boundary, in EPSG:4326.
label_point_func=lambda feature: None,
)