def encode_path_from_geo_chrono(self, lat, lon, latest_bce_ce, earliest_bce_ce, chrono_prefix=''): """ encodes an event path from numeric lat, lon, and date values """ gm = GlobalMercator() geo_path = gm.lat_lon_to_quadtree(lat, lon) ch = ChronoTile() chrono_path = ch.encode_path_from_bce_ce(latest_bce_ce, earliest_bce_ce, chrono_prefix) return self.encode_path_from_geo_chrono_paths(geo_path, chrono_path)
def encode_path_from_geo_chrono(self, lat, lon, latest_bce_ce, earliest_bce_ce, chrono_prefix=''): """ encodes an event path from numeric lat, lon, and date values """ gm = GlobalMercator() geo_path = gm.lat_lon_to_quadtree(lat, lon) ch = ChronoTile() chrono_path = ch.encode_path_from_bce_ce(latest_bce_ce, earliest_bce_ce, chrono_prefix) return self.encode_path_from_geo_chrono_paths(geo_path, chrono_path)
def _process_chrono(self): """ Finds chronological / date ranges in GeoJSON features for indexing. More than 1 date range per item is OK. """ self.chrono_specified = False if 'features' in self.oc_item.json_ld: for feature in self.oc_item.json_ld['features']: bad_time = False try: # time is in ISO 8601 time iso_start = feature['when']['start'] except KeyError: bad_time = True try: # time is in ISO 8601 time iso_stop = feature['when']['stop'] except KeyError: bad_time = True try: when_type = feature['when']['type'] except KeyError: when_type = False try: ref_type = feature['when']['reference-type'] if ref_type == 'specified': self.chrono_specified = True except KeyError: ref_type = False if when_type == 'oc-gen:formation-use-life' \ and bad_time is False: # convert GeoJSON-LD ISO 8601 to numeric start = ISOyears().make_float_from_iso(iso_start) stop = ISOyears().make_float_from_iso(iso_stop) chrono_tile = ChronoTile() if 'form_use_life_chrono_tile' not in self.fields: self.fields['form_use_life_chrono_tile'] = [] if 'form_use_life_chrono_earliest' not in self.fields: self.fields['form_use_life_chrono_earliest'] = [] if 'form_use_life_chrono_latest' not in self.fields: self.fields['form_use_life_chrono_latest'] = [] self.fields['form_use_life_chrono_tile'].append( chrono_tile.encode_path_from_bce_ce( start, stop, '10M-' ) ) self.fields['form_use_life_chrono_earliest'].append(start) self.fields['form_use_life_chrono_latest'].append(stop)
def _process_chrono(self): """ Finds chronological / date ranges in GeoJSON features for indexing. More than 1 date range per item is OK. """ self.chrono_specified = False if "features" in self.oc_item.json_ld: for feature in self.oc_item.json_ld["features"]: bad_time = False try: # time is in ISO 8601 time iso_start = feature["when"]["start"] except KeyError: bad_time = True try: # time is in ISO 8601 time iso_stop = feature["when"]["stop"] except KeyError: bad_time = True try: when_type = feature["when"]["type"] except KeyError: when_type = False try: ref_type = feature["when"]["reference-type"] if ref_type == "specified": self.chrono_specified = True except KeyError: ref_type = False if when_type == "oc-gen:formation-use-life" and bad_time is False: # convert GeoJSON-LD ISO 8601 to numeric start = ISOyears().make_float_from_iso(iso_start) stop = ISOyears().make_float_from_iso(iso_stop) chrono_tile = ChronoTile() if "form_use_life_chrono_tile" not in self.fields: self.fields["form_use_life_chrono_tile"] = [] if "form_use_life_chrono_earliest" not in self.fields: self.fields["form_use_life_chrono_earliest"] = [] if "form_use_life_chrono_latest" not in self.fields: self.fields["form_use_life_chrono_latest"] = [] self.fields["form_use_life_chrono_tile"].append( chrono_tile.encode_path_from_bce_ce(start, stop, "10M-") ) self.fields["form_use_life_chrono_earliest"].append(start) self.fields["form_use_life_chrono_latest"].append(stop)