11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
12 # details. |
12 # details. |
13 # |
13 # |
14 # You should have received a copy of the GNU Lesser General Public License along |
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/>. |
15 # with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 """cubicweb-geonames schema |
16 |
17 |
17 """cubicweb-geonames schema""" |
18 See geonames readme.txt for more details. |
|
19 """ |
18 |
20 |
19 from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation, |
21 from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation, |
20 String, Int, BigInt, Float, Date) |
22 String, Int, BigInt, Float, Date) |
21 from cubicweb.schemas.base import ExternalUri |
|
22 |
23 |
23 """ |
|
24 See geonames readme.txt for more details. |
|
25 """ |
|
26 |
24 |
27 class TestLocation(EntityType): |
25 class TestLocation(EntityType): |
28 """ |
26 """ |
29 Entity type for location of Geonames. |
27 Entity type for location of Geonames. |
30 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
28 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
31 """ |
29 """ |
32 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
30 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
33 geonameid = Int(required=True, unique=True, indexed=True) |
31 geonameid = Int(required=True, unique=True, indexed=True) |
|
32 |
34 |
33 |
35 class Location(EntityType): |
34 class Location(EntityType): |
36 """ |
35 """ |
37 Entity type for location of Geonames. |
36 Entity type for location of Geonames. |
38 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
37 See cities1000.zip, cities5000.zip, cities15000.zip and allCountries.txt |
46 longitude = Float(indexed=True) |
45 longitude = Float(indexed=True) |
47 feature_class = String(maxsize=1, indexed=True) |
46 feature_class = String(maxsize=1, indexed=True) |
48 feature_code = SubjectRelation('FeatureCode', cardinality='?*', inlined=True) |
47 feature_code = SubjectRelation('FeatureCode', cardinality='?*', inlined=True) |
49 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
48 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
50 alternate_country_code = String(maxsize=60) |
49 alternate_country_code = String(maxsize=60) |
51 main_administrative_region = SubjectRelation('AdministrativeRegion', cardinality='?*', inlined=True) |
50 main_administrative_region = SubjectRelation('AdministrativeRegion', |
52 second_administrative_region = SubjectRelation('AdministrativeRegion', cardinality='?*', inlined=True) |
51 cardinality='?*', inlined=True) |
|
52 second_administrative_region = SubjectRelation('AdministrativeRegion', |
|
53 cardinality='?*', inlined=True) |
53 admin_code_1 = String(maxsize=124) |
54 admin_code_1 = String(maxsize=124) |
54 admin_code_2 = String(maxsize=124) |
55 admin_code_2 = String(maxsize=124) |
55 admin_code_3 = String(maxsize=20) |
56 admin_code_3 = String(maxsize=20) |
56 admin_code_4 = String(maxsize=20) |
57 admin_code_4 = String(maxsize=20) |
57 population = BigInt(indexed=True) |
58 population = BigInt(indexed=True) |
58 elevation = Int(indexed=True) |
59 elevation = Int(indexed=True) |
59 gtopo30 = Int(indexed=True) |
60 gtopo30 = Int(indexed=True) |
60 timezone = SubjectRelation('TimeZone', cardinality='?*', inlined=True) |
61 timezone = SubjectRelation('TimeZone', cardinality='?*', inlined=True) |
61 geonames_date = Date() |
62 geonames_date = Date() |
62 |
63 |
|
64 |
63 class LocationName(EntityType): |
65 class LocationName(EntityType): |
64 """ |
66 """ |
65 Name of a Location |
67 Name of a Location |
66 """ |
68 """ |
67 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
69 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
68 language = SubjectRelation('Language', cardinality='?*', inlined=True) |
70 language = SubjectRelation('Language', cardinality='?*', inlined=True) |
69 alternatenamesid = Int(indexed=True) |
71 alternatenamesid = Int(indexed=True) |
|
72 |
70 |
73 |
71 class FeatureCode(EntityType): |
74 class FeatureCode(EntityType): |
72 """ |
75 """ |
73 Entity type for feature codes of Geonames. |
76 Entity type for feature codes of Geonames. |
74 See featureCodes_en.txt |
77 See featureCodes_en.txt |
75 """ |
78 """ |
76 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
79 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
77 main_code = String(maxsize=1, indexed=True) |
80 main_code = String(maxsize=1, indexed=True) |
78 code = String(maxsize=12) |
81 code = String(maxsize=12) |
79 description = String(maxsize=1024, fulltextindexed=True) |
82 description = String(maxsize=1024, fulltextindexed=True) |
|
83 |
80 |
84 |
81 class AdministrativeRegion(EntityType): |
85 class AdministrativeRegion(EntityType): |
82 """ |
86 """ |
83 Entity type for administrative regions of Geonames. |
87 Entity type for administrative regions of Geonames. |
84 See admin1CodesASCII.txt and admin2Codes.txt |
88 See admin1CodesASCII.txt and admin2Codes.txt |
87 code = String(maxsize=64, indexed=True) |
91 code = String(maxsize=64, indexed=True) |
88 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
92 country = SubjectRelation('Country', cardinality='?*', inlined=True) |
89 geonameid = Int(indexed=True) |
93 geonameid = Int(indexed=True) |
90 asciiname = String(maxsize=200, fulltextindexed=True) |
94 asciiname = String(maxsize=200, fulltextindexed=True) |
91 |
95 |
|
96 |
92 class Language(EntityType): |
97 class Language(EntityType): |
93 """ |
98 """ |
94 Entity type for languages of Geonames. |
99 Entity type for languages of Geonames. |
95 See admin1CodesASCII.txt and admin2Codes.txt |
100 See admin1CodesASCII.txt and admin2Codes.txt |
96 """ |
101 """ |
97 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
102 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
98 iso_639_3 = String(maxsize=3, indexed=True) |
103 iso_639_3 = String(maxsize=3, indexed=True) |
99 iso_639_2 = String(maxsize=64, indexed=True) |
104 iso_639_2 = String(maxsize=64, indexed=True) |
100 iso_639_1 = String(maxsize=3, indexed=True) |
105 iso_639_1 = String(maxsize=3, indexed=True) |
101 |
106 |
|
107 |
102 class Continent(EntityType): |
108 class Continent(EntityType): |
103 """ |
109 """ |
104 Entity type for continents of geonames. |
110 Entity type for continents of geonames. |
105 """ |
111 """ |
106 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
112 name = String(maxsize=1024, indexed=True, fulltextindexed=True) |
107 code = String(maxsize=2, indexed=True) |
113 code = String(maxsize=2, indexed=True) |
108 geonameid = Int(indexed=True) |
114 geonameid = Int(indexed=True) |
|
115 |
109 |
116 |
110 class Country(EntityType): |
117 class Country(EntityType): |
111 """ |
118 """ |
112 Entity type for countries of geonames. |
119 Entity type for countries of geonames. |
113 See countryInfo.txt |
120 See countryInfo.txt |
131 postal_code_regex = String(maxsize=200) |
138 postal_code_regex = String(maxsize=200) |
132 languages_code = String(maxsize=200) |
139 languages_code = String(maxsize=200) |
133 neighbours_code = String(maxsize=200) |
140 neighbours_code = String(maxsize=200) |
134 equivalent_fips = String(maxsize=2) |
141 equivalent_fips = String(maxsize=2) |
135 |
142 |
|
143 |
136 class TimeZone(EntityType): |
144 class TimeZone(EntityType): |
137 """ |
145 """ |
138 Entity type for timezone of geonames. |
146 Entity type for timezone of geonames. |
139 See timeZones.txt |
147 See timeZones.txt |
140 """ |
148 """ |
141 code = String(maxsize=1024, indexed=True) |
149 code = String(maxsize=1024, indexed=True) |
142 gmt = Float() |
150 gmt = Float() |
143 dst = Float() |
151 dst = Float() |
144 raw_offset = Float() |
152 raw_offset = Float() |
145 |
153 |
|
154 |
146 class used_language(RelationDefinition): |
155 class used_language(RelationDefinition): |
147 subject = 'Country' |
156 subject = 'Country' |
148 object = 'Language' |
157 object = 'Language' |
149 cardinality = '**' |
158 cardinality = '**' |
150 |
159 |
|
160 |
151 class neighbour_of(RelationDefinition): |
161 class neighbour_of(RelationDefinition): |
152 subject = 'Country' |
162 subject = 'Country' |
153 object = 'Country' |
163 object = 'Country' |
154 cardinality = '**' |
164 cardinality = '**' |