def get_location(self, call_id, address): """Geocodes an address, by matching it to a location record. Args: call_id (str): A geocode call identifier, for logging purposes. address (str): An address (e.g., '123 main st, boulder co'). Returns: A JSON-formatted string containing results and a status code. """ # Lazily initialize the geocoder handle. if self.__geocoder_handle is None: self.__geocoder_handle = pxpointsc.geocoder_init( self.__data_catalog) # Create an input table from the call id and the address input_table = self.create_address_input_table(call_id, address) # Call the geocoder and get the results output_table, error_table, return_code, _ = pxpointsc.geocoder_geocode( self.__geocoder_handle, input_table, GeoSpatial.__GEOCODING_OUTPUT_COLS, GeoSpatial.__ERROR_TABLE_COLS, "" # we don't use any processing options right now ) # Build and return the JSON encoding of the results status, json_results = self.create_json_results_with_status( output_table, error_table, return_code) return json_results
def geocode(geocoder_handle, address_line, city_line): input_table = create_geocode_input_table(0, address_line, city_line) (output_table, error_table, return_code, return_message) = pxpointsc.geocoder_geocode( geocoder_handle, input_table, OUTPUT_TABLE_COLUMNS_DEF, ERROR_TABLE_COLUMNS_DEF, '' ) if output_table != None and output_table.nrows > 0: print('Geocode OK') else: print(return_message)