Skip to content

Commit 593a370

Browse files
committed
towards v1.1
1 parent 9d30ac4 commit 593a370

15 files changed

Lines changed: 474 additions & 27 deletions

File tree

src/pyglottography/commands/showmap.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"""
44
import json
55
import pathlib
6+
import argparse
67
import webbrowser
78

89
from pycldf.media import File
910
from pycldf.cli_util import add_dataset, get_dataset
1011
from clldutils.misc import data_url
12+
from clldutils.clilib import PathType
1113
from mako.lookup import Template
1214

1315
from pyglottography.util import bbox
@@ -16,17 +18,20 @@
1618
def register(parser):
1719
add_dataset(parser)
1820
parser.add_argument('map-id')
21+
parser.add_argument(
22+
'-o', '--output',
23+
type=PathType(type='file', must_exist=False),
24+
default=pathlib.Path('.') / 'index.html')
25+
parser.add_argument('--test', action='store_true', default=False, help=argparse.SUPPRESS)
1926

2027

2128
def run(args):
2229
"""
2330
Assemble geo-referenced scan and associated polygons.
2431
Format as standalone HTML page using leaflet.
2532
"""
26-
out = pathlib.Path('.')
27-
28-
def render(fname, **vars):
29-
out.joinpath(fname).write_text(
33+
def render(**vars):
34+
args.output.write_text(
3035
Template(filename=str(pathlib.Path(__file__).parent / 'map.html.mako')).render(**vars),
3136
encoding='utf8')
3237

@@ -59,7 +64,6 @@ def render(fname, **vars):
5964
else:
6065
bounds = bounds.read_json()['bbox']
6166
render(
62-
'index.html',
6367
map=m,
6468
img=data_url(img.read(), 'image/jpeg') if img else None,
6569
geojson=json.dumps(dict(type='FeatureCollection', features=gfeatures)),
@@ -71,4 +75,5 @@ def render(fname, **vars):
7175
w=4,
7276
)
7377

74-
webbrowser.open(str(out / 'index.html'))
78+
if not args.test:
79+
webbrowser.open(str(args.output)) # pragma: no cover

src/pyglottography/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def schema(self, cldf):
633633
'preserve the original metadata and a point of reference for the aggregated shapes.')
634634

635635
def cmd_readme(self, args):
636-
if len(self.features) > 500:
636+
if len(self.features) > 500: # pragma: no cover
637637
f = json.dumps(self.bounding_box_as_feature())
638638
else:
639639
max_geojson_len = getattr(args, 'max_geojson_len', 10000)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
includeme
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.csv text eol=crlf
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
{
2+
"@context": [
3+
"http://www.w3.org/ns/csvw",
4+
{
5+
"@language": "en"
6+
}
7+
],
8+
"dc:conformsTo": "http://cldf.clld.org/v1.0/terms.rdf#Generic",
9+
"dc:source": "sources.bib",
10+
"dc:spatial": "westlimit=89.7; southlimit=-39.1; eastlimit=153.5; northlimit=27.7",
11+
"prov:wasGeneratedBy": [
12+
{
13+
"dc:title": "python",
14+
"dc:description": "3.12.3"
15+
},
16+
{
17+
"dc:title": "python-packages",
18+
"dc:relation": "requirements.txt"
19+
}
20+
],
21+
"rdf:ID": "author2022word",
22+
"rdf:type": "http://www.w3.org/ns/dcat#Distribution",
23+
"tables": [
24+
{
25+
"dc:conformsTo": "http://cldf.clld.org/v1.0/terms.rdf#MediaTable",
26+
"dc:extent": 3,
27+
"tableSchema": {
28+
"columns": [
29+
{
30+
"datatype": {
31+
"base": "string",
32+
"format": "[a-zA-Z0-9_\\-]+"
33+
},
34+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#id",
35+
"required": true,
36+
"name": "ID"
37+
},
38+
{
39+
"datatype": "string",
40+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#name",
41+
"required": false,
42+
"name": "Name"
43+
},
44+
{
45+
"datatype": "string",
46+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#description",
47+
"required": false,
48+
"name": "Description"
49+
},
50+
{
51+
"datatype": {
52+
"base": "string",
53+
"format": "[^/]+/.+"
54+
},
55+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#mediaType",
56+
"required": true,
57+
"name": "Media_Type"
58+
},
59+
{
60+
"datatype": "anyURI",
61+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#downloadUrl",
62+
"required": false,
63+
"name": "Download_URL"
64+
},
65+
{
66+
"datatype": "string",
67+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#pathInZip",
68+
"required": false,
69+
"name": "Path_In_Zip"
70+
}
71+
],
72+
"primaryKey": [
73+
"ID"
74+
]
75+
},
76+
"url": "media.csv"
77+
},
78+
{
79+
"dc:conformsTo": "http://cldf.clld.org/v1.0/terms.rdf#LanguageTable",
80+
"dc:extent": 2,
81+
"tableSchema": {
82+
"columns": [
83+
{
84+
"datatype": {
85+
"base": "string",
86+
"format": "[a-zA-Z0-9_\\-]+"
87+
},
88+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#id",
89+
"required": true,
90+
"name": "ID"
91+
},
92+
{
93+
"datatype": "string",
94+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#name",
95+
"required": false,
96+
"name": "Name"
97+
},
98+
{
99+
"datatype": "string",
100+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#macroarea",
101+
"required": false,
102+
"name": "Macroarea"
103+
},
104+
{
105+
"datatype": {
106+
"base": "decimal",
107+
"minimum": "-90",
108+
"maximum": "90"
109+
},
110+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#latitude",
111+
"required": false,
112+
"name": "Latitude"
113+
},
114+
{
115+
"datatype": {
116+
"base": "decimal",
117+
"minimum": "-180",
118+
"maximum": "180"
119+
},
120+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#longitude",
121+
"required": false,
122+
"name": "Longitude"
123+
},
124+
{
125+
"datatype": {
126+
"base": "string",
127+
"format": "[a-z0-9]{4}[1-9][0-9]{3}"
128+
},
129+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#glottocode",
130+
"required": false,
131+
"valueUrl": "http://glottolog.org/resource/languoid/id/{Glottocode}",
132+
"name": "Glottocode"
133+
},
134+
{
135+
"datatype": {
136+
"base": "string",
137+
"format": "[a-z]{3}"
138+
},
139+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#iso639P3code",
140+
"required": false,
141+
"name": "ISO639P3code"
142+
},
143+
{
144+
"dc:description": "List of identifiers of features that were aggregated to create the feature referenced by Speaker_Area.",
145+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#contributionReference",
146+
"separator": " ",
147+
"name": "Feature_IDs"
148+
},
149+
{
150+
"dc:description": "https://glottolog.org/meta/glossary#Languoid",
151+
"datatype": {
152+
"base": "string",
153+
"format": "dialect|language|family"
154+
},
155+
"name": "Glottolog_Languoid_Level"
156+
},
157+
{
158+
"dc:description": "Name of the top-level family for the languoid in the Glottolog classification. A null value in this column marks 1) top-level families in case Glottolog_Languoid_Level is 'family' and 2) isolates in case Glottolog_Languoid_Level is 'language'.",
159+
"name": "Family"
160+
},
161+
{
162+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#speakerArea",
163+
"name": "Speaker_Area"
164+
}
165+
],
166+
"foreignKeys": [
167+
{
168+
"columnReference": [
169+
"Speaker_Area"
170+
],
171+
"reference": {
172+
"resource": "media.csv",
173+
"columnReference": [
174+
"ID"
175+
]
176+
}
177+
},
178+
{
179+
"columnReference": [
180+
"Feature_IDs"
181+
],
182+
"reference": {
183+
"resource": "contributions.csv",
184+
"columnReference": [
185+
"ID"
186+
]
187+
}
188+
}
189+
],
190+
"primaryKey": [
191+
"ID"
192+
]
193+
},
194+
"url": "languages.csv"
195+
},
196+
{
197+
"dc:conformsTo": "http://cldf.clld.org/v1.0/terms.rdf#ContributionTable",
198+
"dc:description": "We list the individual features from the source dataset as contributions in order to preserve the original metadata and a point of reference for the aggregated shapes.",
199+
"dc:extent": 31,
200+
"tableSchema": {
201+
"columns": [
202+
{
203+
"datatype": {
204+
"base": "string",
205+
"format": "[a-zA-Z0-9_\\-]+"
206+
},
207+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#id",
208+
"required": true,
209+
"name": "ID"
210+
},
211+
{
212+
"datatype": "string",
213+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#name",
214+
"required": false,
215+
"name": "Name"
216+
},
217+
{
218+
"datatype": "string",
219+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#description",
220+
"required": false,
221+
"name": "Description"
222+
},
223+
{
224+
"datatype": "string",
225+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#contributor",
226+
"required": false,
227+
"name": "Contributor"
228+
},
229+
{
230+
"datatype": "string",
231+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#citation",
232+
"required": false,
233+
"name": "Citation"
234+
},
235+
{
236+
"dc:description": "References a Glottolog languoid most closely matching the linguistic entity described by the feature.",
237+
"datatype": {
238+
"base": "string",
239+
"format": "[a-z0-9]{4}[1-9][0-9]{3}"
240+
},
241+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#glottocode",
242+
"valueUrl": "http://glottolog.org/resource/languoid/id/{Glottocode}",
243+
"name": "Glottocode"
244+
},
245+
{
246+
"dc:description": "The time period to which the feature relates, specified as year AD or with the keyword 'traditional', meaning either the time of contact with European maritime powers or period when an ancient language was spoken.",
247+
"datatype": {
248+
"base": "string",
249+
"format": "[0-9]{3,4}|traditional"
250+
},
251+
"propertyUrl": "http://purl.org/dc/terms/temporal",
252+
"name": "Year"
253+
},
254+
{
255+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#source",
256+
"separator": ";",
257+
"name": "Source"
258+
},
259+
{
260+
"dc:description": "Contributions of type 'feature' are linked to GeoJSON files that store the geo data. can be related to various kinds of media. Contributions of type 'map' are linked to the corresponding scans of maps and geo-data derived from these.",
261+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#mediaReference",
262+
"separator": " ",
263+
"name": "Media_IDs"
264+
},
265+
{
266+
"dc:description": "There are two types of contributions: Individual geo-features as depicted in the source and images of maps.",
267+
"datatype": {
268+
"base": "string",
269+
"format": "map|feature"
270+
},
271+
"name": "Type"
272+
},
273+
{
274+
"dc:description": "Contributions of type 'feature' link to the maps on which they appear.",
275+
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#contributionReference",
276+
"separator": " ",
277+
"name": "Map_IDs"
278+
}
279+
],
280+
"foreignKeys": [
281+
{
282+
"columnReference": [
283+
"Media_IDs"
284+
],
285+
"reference": {
286+
"resource": "media.csv",
287+
"columnReference": [
288+
"ID"
289+
]
290+
}
291+
},
292+
{
293+
"columnReference": [
294+
"Map_IDs"
295+
],
296+
"reference": {
297+
"resource": "contributions.csv",
298+
"columnReference": [
299+
"ID"
300+
]
301+
}
302+
}
303+
],
304+
"primaryKey": [
305+
"ID"
306+
]
307+
},
308+
"url": "contributions.csv"
309+
}
310+
]
311+
}

0 commit comments

Comments
 (0)