|
1 # copyright 2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This program is free software: you can redistribute it and/or modify it under |
|
5 # the terms of the GNU Lesser General Public License as published by the Free |
|
6 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
7 # any later version. |
|
8 # |
|
9 # This program is distributed in the hope that it will be useful, but WITHOUT |
|
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
12 # details. |
|
13 # |
|
14 # You should have received a copy of the GNU Lesser General Public License along |
|
15 # with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
|
17 """cubicweb-geonames schema""" |
|
18 |
|
19 from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation, |
|
20 String, Int, BigInt, Float, Date) |
|
21 from cubicweb.schemas.base import ExternalUri |
|
22 |
|
23 """ |
|
24 See geonames readme.txt for more details. |
|
25 """ |
|
26 |
|
27 class TestLocation(EntityType): |
|
28 """ |
|
29 Entity type for location of Geonames. |
|
30 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
|
31 """ |
|
32 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
33 geonameid = Int(required=True, unique=True, indexed=True) |
|
34 |
|
35 class Location(EntityType): |
|
36 """ |
|
37 Entity type for location of Geonames. |
|
38 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
|
39 """ |
|
40 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
41 geonameid = Int(indexed=True) |
|
42 asciiname = String(maxsize=200, fulltextindexed=True) |
|
43 alternatenames = String(fulltextindexed=True) |
|
44 names = SubjectRelation('LocationName', cardinality='**') |
|
45 latitude = Float(indexed=True) |
|
46 longitude = Float(indexed=True) |
|
47 feature_class = String(maxsize=1, indexed=True) |
|
48 feature_code = SubjectRelation('FeatureCode', cardinality='?*', inlined=True) |
|
49 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
|
50 alternate_country_code = String(maxsize=60) |
|
51 main_administrative_region = SubjectRelation('AdministrativeRegion', cardinality='?*', inlined=True) |
|
52 second_administrative_region = SubjectRelation('AdministrativeRegion', cardinality='?*', inlined=True) |
|
53 admin_code_1 = String(maxsize=124) |
|
54 admin_code_2 = String(maxsize=124) |
|
55 admin_code_3 = String(maxsize=20) |
|
56 admin_code_4 = String(maxsize=20) |
|
57 population = BigInt(indexed=True) |
|
58 elevation = Int(indexed=True) |
|
59 gtopo30 = Int(indexed=True) |
|
60 timezone = SubjectRelation('TimeZone', cardinality='?*', inlined=True) |
|
61 geonames_date = Date() |
|
62 |
|
63 class LocationName(EntityType): |
|
64 """ |
|
65 Name of a Location |
|
66 """ |
|
67 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
68 language = SubjectRelation('Language', cardinality='?*', inlined=True) |
|
69 alternatenamesid = Int(indexed=True) |
|
70 |
|
71 class FeatureCode(EntityType): |
|
72 """ |
|
73 Entity type for feature codes of Geonames. |
|
74 See featureCodes_en.txt |
|
75 """ |
|
76 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
77 main_code = String(maxsize=1, indexed=True) |
|
78 code = String(maxsize=12) |
|
79 description = String(maxsize=1024, fulltextindexed=True) |
|
80 |
|
81 class AdministrativeRegion(EntityType): |
|
82 """ |
|
83 Entity type for administrative regions of Geonames. |
|
84 See admin1CodesASCII.txt and admin2Codes.txt |
|
85 """ |
|
86 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
87 code = String(maxsize=64, indexed=True) |
|
88 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
|
89 geonameid = Int(indexed=True) |
|
90 asciiname = String(maxsize=200, fulltextindexed=True) |
|
91 |
|
92 class Language(EntityType): |
|
93 """ |
|
94 Entity type for languages of Geonames. |
|
95 See admin1CodesASCII.txt and admin2Codes.txt |
|
96 """ |
|
97 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
98 iso_639_3 = String(maxsize=3, indexed=True) |
|
99 iso_639_2 = String(maxsize=64, indexed=True) |
|
100 iso_639_1 = String(maxsize=3, indexed=True) |
|
101 |
|
102 class Continent(EntityType): |
|
103 """ |
|
104 Entity type for continents of geonames. |
|
105 """ |
|
106 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
107 code = String(maxsize=2, indexed=True) |
|
108 geonameid = Int(indexed=True) |
|
109 |
|
110 class Country(EntityType): |
|
111 """ |
|
112 Entity type for countries of geonames. |
|
113 See countryInfo.txt |
|
114 """ |
|
115 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
|
116 code = String(maxsize=2, indexed=True) |
|
117 code3 = String(maxsize=3, indexed=True) |
|
118 codenum = Int(indexed=True) |
|
119 fips = String(maxsize=2) |
|
120 capital = String(maxsize=1024, fulltextindexed=True) |
|
121 area = Float(indexed=True) |
|
122 population = BigInt(indexed=True) |
|
123 continent_code = String(maxsize=3) |
|
124 continent = SubjectRelation('Continent', cardinality='?*', inlined=True) |
|
125 tld = String(maxsize=64) |
|
126 currency = String(maxsize=1024, fulltextindexed=True) |
|
127 currency_code = String(maxsize=64) |
|
128 geonameid = Int(indexed=True) |
|
129 phone = String(maxsize=64) |
|
130 postal_code = String(maxsize=200) |
|
131 postal_code_regex = String(maxsize=200) |
|
132 languages_code = String(maxsize=200) |
|
133 neighbours_code = String(maxsize=200) |
|
134 equivalent_fips = String(maxsize=2) |
|
135 |
|
136 class TimeZone(EntityType): |
|
137 """ |
|
138 Entity type for timezone of geonames. |
|
139 See timeZones.txt |
|
140 """ |
|
141 code = String(maxsize=1024, indexed=True) |
|
142 gmt = Float() |
|
143 dst = Float() |
|
144 raw_offset = Float() |
|
145 |
|
146 class used_language(RelationDefinition): |
|
147 subject = 'Country' |
|
148 object = 'Language' |
|
149 cardinality = '**' |
|
150 |
|
151 class neighbour_of(RelationDefinition): |
|
152 subject = 'Country' |
|
153 object = 'Country' |
|
154 cardinality = '**' |