def __init__(self): """Inits CoordinateTransform. Initializes the logger "ge_search". """ self._utils = utils.SearchUtils() self._logger = self._utils.logger self._dms_pattern = ( r"\s*(\d+)\s*°\s*(\d+)\s*(?:ʹ|′|')\s*(\d+\.?\d*)\s*(?:ʺ|\"|″)" r"\s*([EWNS])\s*") self._ddm_pattern = ( r"\s*(\d+)\s*°\s*(\d+\.?\d*)\s*(?:ʹ|′|')\s*([EWNS])\s*") self._dd_pattern = r"\s*(-?\d+\.?\d*)\s*(?:°)?\s*[EWNS]?" self._mgrs_pattern = r"\s*\d?\d[A-Z]([A-Z][A-Z])?(\d\d){0,5}\s*" self._utm_pattern = (r"(\d?\d)\s*([A-Z])\s*(\d+\.?\d*)\s*M\s*E\s*" r"\s*(\d+\.?\d*)\s*M\s*N\s*") # List of lists for storing the input pattern and types self._input_pattern_types = [[self._dms_pattern, "DMS"], [self._ddm_pattern, "DDM"], [self._utm_pattern, "UTM"], [self._mgrs_pattern, "MGRS"], [self._dd_pattern, "DD"]] self._valid_latitude_directions = ["S", "N"] self._valid_longitude_directions = ["E", "W"] self._dms_negative_directions = ["S", "W"] self._e1 = ((1 - math.sqrt(1 - CoordinateTransform.ECC_SQUARED)) / (1 + math.sqrt(1 - CoordinateTransform.ECC_SQUARED))) self._e1_prime = (CoordinateTransform.ECC_SQUARED / (1 - CoordinateTransform.ECC_SQUARED))
def __init__(self): """Inits SearchGoogle. Initializes the logger "ge_search". """ self.utils = utils.SearchUtils() self.logger = self.utils.logger
def __init__(self): """Inits FederatedSearch. Initializes the logger "ge_search". """ self.utils = utils.SearchUtils() self.logger = self.utils.logger # Create coordinate and places search objects self._coordinate = coordinate_search_handler.CoordinateSearch() self._geplaces = geplaces_search_handler.PlacesSearch() # Get Style information from Places or Coordinate search handlers. self._style = self._geplaces.style
def __init__(self): """Inits ExampleSearch. Initializes the logger "ge_search". Initializes templates for kml, json, placemark templates for the KML/JSONP output. Initializes parameters for establishing a connection to the database. """ self.utils = utils.SearchUtils() constants = geconstants.Constants() configs = self.utils.GetConfigs( os.path.join(geconstants.SEARCH_CONFIGS_DIR, "ExampleSearch.conf")) style_template = self.utils.style_template self._jsonp_call = self.utils.jsonp_functioncall self._geom = """ <name>%s</name> <styleUrl>%s</styleUrl> <Snippet>%s</Snippet> <description>%s</description> %s\ """ self._json_geom = """ { "name": "%s", "Snippet": "%s", "description": "%s", %s }\ """ self._placemark_template = self.utils.placemark_template self._kml_template = self.utils.kml_template self._json_template = self.utils.json_template self._json_placemark_template = self.utils.json_placemark_template self._example_query_template = (Template(constants.example_query)) self.logger = self.utils.logger self._user = configs.get("user") self._hostname = configs.get("host") self._port = configs.get("port") self._database = configs.get("databasename") if not self._database: self._database = constants.defaults.get("example.database") self._pool = ThreadedConnectionPool( int(configs.get("minimumconnectionpoolsize")), int(configs.get("maximumconnectionpoolsize")), database=self._database, user=self._user, host=self._hostname, port=int(self._port)) self._style = style_template.substitute( balloonBgColor=configs.get("balloonstyle.bgcolor"), balloonTextColor=configs.get("balloonstyle.textcolor"), balloonText=configs.get("balloonstyle.text"), iconStyleScale=configs.get("iconstyle.scale"), iconStyleHref=configs.get("iconstyle.href"), lineStyleColor=configs.get("linestyle.color"), lineStyleWidth=configs.get("linestyle.width"), polyStyleColor=configs.get("polystyle.color"), polyStyleColorMode=configs.get("polystyle.colormode"), polyStyleFill=configs.get("polystyle.fill"), polyStyleOutline=configs.get("polystyle.outline"), listStyleHref=configs.get("iconstyle.href"))
def __init__(self): """Inits POISearch. Initializes the logger "ge_search". Initializes templates for kml, placemark templates for the KML output. Initializes parameters for establishing a connection to the database. """ self.utils = utils.SearchUtils() constants = geconstants.Constants() configs = self.utils.GetConfigs( os.path.join(geconstants.SEARCH_CONFIGS_DIR, "PoiSearch.conf")) style_template = self.utils.style_template self._jsonp_call = self.utils.jsonp_functioncall self._geom = """ <name>%s</name>, <styleUrl>%s</styleUrl> <description>%s</description>, %s\ """ self._json_geom = """ { "name" : "%s", "description" : "%s", %s } """ self._placemark_template = self.utils.placemark_template self._kml_template = self.utils.kml_template self._json_template = self.utils.json_template self._json_placemark_template = self.utils.json_placemark_template self._host_db_name_by_target_query = constants.host_db_name_by_target_query self._poi_info_by_host_db_name_query = ( constants.poi_info_by_host_db_name_query) self.logger = logging.getLogger("ge_search") poisearch_database = configs.get("searchdatabasename") if not poisearch_database: poisearch_database = constants.defaults.get("poisearch.database") gestream_database = configs.get("streamdatabasename") if not gestream_database: gestream_database = constants.defaults.get("gestream.database") poiquery_database = configs.get("poidatabasename") if not poiquery_database: poiquery_database = constants.defaults.get("poiquery.database") self._search_pool = ThreadedConnectionPool( int(configs.get("minimumconnectionpoolsize")), int(configs.get("maximumconnectionpoolsize")), database=poisearch_database, user=configs.get("user"), host=configs.get("host"), port=int(configs.get("port"))) self._poi_pool = ThreadedConnectionPool( int(configs.get("minimumconnectionpoolsize")), int(configs.get("maximumconnectionpoolsize")), database=poiquery_database, user=configs.get("user"), host=configs.get("host"), port=int(configs.get("port"))) self._stream_pool = ThreadedConnectionPool( int(configs.get("minimumconnectionpoolsize")), int(configs.get("maximumconnectionpoolsize")), database=gestream_database, user=configs.get("user"), host=configs.get("host"), port=int(configs.get("port"))) self._style = style_template.substitute( balloonBgColor=configs.get("balloonstyle.bgcolor"), balloonTextColor=configs.get("balloonstyle.textcolor"), balloonText=configs.get("balloonstyle.text"), iconStyleScale=configs.get("iconstyle.scale"), iconStyleHref=configs.get("iconstyle.href"), lineStyleColor=configs.get("linestyle.color"), lineStyleWidth=configs.get("linestyle.width"), polyStyleColor=configs.get("polystyle.color"), polyStyleColorMode=configs.get("polystyle.colormode"), polyStyleFill=configs.get("polystyle.fill"), polyStyleOutline=configs.get("polystyle.outline"), listStyleHref=configs.get("iconstyle.href")) # Parameters for calculating the bounding box. self.latitude_center = constants.latitude_center self.longitude_center = constants.longitude_center self.latitude_span = constants.latitude_span self.longitude_span = constants.longitude_span self.srid = constants.srid self.usebbox = configs.get("usebbox").lower() == "true" self.expandbbox = configs.get("expandbbox").lower() == "true" # Calculate default bounding box with latitude span = 180(degrees) and # longitude span = 360(degrees). self.world_bounds = self.__CreateBboxFromParameters( self.latitude_center, self.longitude_center, self.latitude_span, self.longitude_span) # Create federated search handler object for # performing super federated search. try: self._fed_search = federated_search_handler.FederatedSearch() except Exception as e: self.logger.warning("Federated search is not available due to an " "unexpected error, %s.", e) self._fed_search = None
def __init__(self): """Inits Custom POI Search. Initializes the logger "ge_search". Initializes templates for kml, json, placemark templates for the KML/JSON output. """ # For the sake of simplicity, we presently look for # "name", "geometry", "icon", "vicinity" tags only in the # response and ignore the others. self._reqd_tags = ["name", "geometry", "icon", "vicinity"] self._f_name = "Custom POI Search." self._no_results = "No search results found." self._kml = """<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Folder> <name>${foldername}</name> <open>1</open> <Style id="placemark_label">\ ${style}\ </Style>\ ${placemark} </Folder> </kml> """ self._iconstyle = """ <IconStyle> <scale>1</scale> </IconStyle>\ """ self._linestyle = """ <LineStyle> <color>7fffff00</color> <width>5</width> </LineStyle>\ """ self._polystyle = """ <PolyStyle> <color>7f66ffff</color> <colorMode>normal</colorMode> <fill>1</fill> <outline>1</outline> </PolyStyle> """ self._style = ("%s %s %s" % (self._iconstyle, self._linestyle, self._polystyle)) self._json = """ {\ "Folder": {\ "name": "${name}",\ "Placemark":${placemark}\ }\ }\ """ self._json_template = Template(self._json) self._kml_template = Template(self._kml) # URL to access Google Places database. # output type(xml or json), location, radius and server key are # mandatory parameters required to perform the search. self._baseurl = "https://maps.googleapis.com/maps/api/place/nearbysearch" self._places_api_url = self._baseurl + "/%s?location=%s&radius=%s&key=%s" self.logger = logging.getLogger("ge_search") self._content_type = "Content-type, %s" self.utils = utils.SearchUtils()
def __init__(self): """Inits CoordinateSearch. Initializes the logger "ge_search". Initializes templates for kml, placemark templates for KML/JSONP outputs. """ self.utils = utils.SearchUtils() self._transform = coordinate_transform.CoordinateTransform() configs = self.utils.GetConfigs( os.path.join(geconstants.SEARCH_CONFIGS_DIR, "CoordinateSearch.conf")) self._jsonp_call = self.utils.jsonp_functioncall self._geom = """ <name>%s</name> <styleUrl>%s</styleUrl> <Point> <coordinates>%s,%s</coordinates> </Point>\ """ self._json_geom = """ { "Point": { "coordinates": "%s,%s" } } """ self._kml = """ <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Folder> <name>Coordinate Search Results</name> <open>1</open> <Style id="placemark_label">\ ${style} </Style>\ ${placemark} </Folder> </kml> """ self._kml_template = Template(self._kml) self._placemark_template = self.utils.placemark_template self._json_template = self.utils.json_template self._json_placemark_template = self.utils.json_placemark_template style_template = self.utils.style_template self.coordinates_in_lat_lng_format_ = ["DD", "DMS", "DDM"] self.logger = self.utils.logger self._style = style_template.substitute( balloonBgColor=configs.get("balloonstyle.bgcolor"), balloonTextColor=configs.get("balloonstyle.textcolor"), balloonText=configs.get("balloonstyle.text"), iconStyleScale=configs.get("iconstyle.scale"), iconStyleHref=configs.get("iconstyle.href"), lineStyleColor=configs.get("linestyle.color"), lineStyleWidth=configs.get("linestyle.width"), polyStyleColor=configs.get("polystyle.color"), polyStyleColorMode=configs.get("polystyle.colormode"), polyStyleFill=configs.get("polystyle.fill"), polyStyleOutline=configs.get("polystyle.outline"), listStyleHref=configs.get("iconstyle.href"))