def test_get_location_data(self):
     '''
     Test the translation of location data using google API
     '''
     output = get_formatted_location(GENERIC_PLACE_STRING)
     assert(output["latitude"] > 41.47 )
     assert(output["longitude"] < -4.0 )
     assert(output["place_name"] == "Portillo")
     assert(output["county"] == "Valladolid")
     assert(output["country"] == "Spain")
     assert(output["city"] == "Arrabal de Portillo")
     self.assertFalse("state" in output.keys())
     output2 = get_formatted_location(GENERIC_PLACE_WITH_PLACE)
     assert(output2["latitude"] > 41.53 )
     assert(output2["longitude"] < -4.53)
     assert(output2["county"] == "Valladolid")
     assert(output2["country"] == "Spain")
     assert(output2["place_name"] == "Calle Nuestra Señora De Los Remedios")
     self.assertFalse("state" in output.keys())
     
     output3 = get_formatted_location("La Asunción, Herrera De Duero, Valladolid, Spain")
     assert("city" in output3)
     
     
     output4 = get_formatted_location("")
     assert("raw" in output4)
     self.assertFalse("country" in output4)
     
     output5 = get_formatted_location("Robert;")
     assert("raw" in output5)
     self.assertFalse("country" in output5)
 def test_no_valid_mapbox(self):
     '''
     Test no valid Mapbox
     '''
     set_mapbox_key(WRONG_TOKEN)
     location1 = get_formatted_location("Madrid, Spain")
     assert(not "county" in location1.keys())
     set_mapbox_key_environmental()
     location2 = get_formatted_location("Madrid, Spain")
     assert("county" in location2.keys())
 def test_bug_capital_letters(self):
     '''
     Test Capital Letters are fixed
     '''
     output = get_formatted_location(GENERIC_PLACE_CAPITALS)
     assert(output["place_name"] == "Pz San Juan Evangelista")
     assert(output["country"] == "Spain")
 def test_bug_capital_letters(self):
     '''
     Test Capital Letters are fixed
     '''
     output = get_formatted_location(GENERIC_PLACE_CAPITALS, language="es")
     assert (output["place_name"] == "San Juan Evangelista del Arrabal")
     assert (output["country"] == "España")
Пример #5
0
 def setPlaces(self, event_place, location, language="en" ):
     '''
     This function will introduce the location related to each event
     '''
     if event_place in DATA_PLACES:
         location_data = get_formatted_location(location, language)
         if (location_data == None):
             return False
         else:
             self.gen_data[event_place] = location_data
             return True
     else:
         return False
    def test_get_location_data(self):
        '''
        Test the translation of location data using google API
        '''
        output = get_formatted_location(GENERIC_PLACE_STRING, language="en")
        assert (output["latitude"] > 41.4781556)
        assert (output["longitude"] < -4.0)
        assert (output["city"] == "Portillo")
        assert (output["county"] == "Valladolid")
        assert (output["state"] == "Castile and León")
        assert (output["country"] == "Spain")
        self.assertFalse("place_name" in output.keys())
        output2 = get_formatted_location(GENERIC_PLACE_WITH_PLACE,
                                         language="es")
        assert (output2["latitude"] > 41.535338)
        assert (output2["longitude"] < -4.53061)
        assert (output2["city"] == "La Parrilla")
        assert (output2["county"] == "Valladolid")
        assert (output2["state"] == "Castilla y León")
        assert (output2["country"] == "España")
        assert (output2["place_name"] == "Nuestra Señora de los Remedios")

        assert (get_location_standard(output2) ==
                "La Parrilla, Valladolid, Castilla y León, España")

        output3 = get_formatted_location(
            "La Asunción, Herrera De Duero, Valladolid, Spain", language="es")

        assert ("city" in output3)

        output4 = get_formatted_location("")
        assert ("raw" in output4)
        self.assertFalse("country" in output4)

        #Suggestino from https://stackoverflow.com/questions/47063366/google-maps-geocoding-api-zero-results-example/47092855
        output5 = get_formatted_location(
            "postal_code%3A12345%7Ccountry%3ASE,,,", language="es")
        assert ("raw" in output5)
        self.assertFalse("country" in output5)
Пример #7
0
birth_event.setDate(1900, 1, 1)
all_events.append(birth_event)
residence_event = event_profile("residence")
residence_event.setDate(1910, 1, 1)
all_events.append(residence_event)
baptism_event = event_profile("baptism")
baptism_event.setDate(1901, 1, 12)
all_events.append(baptism_event)
marriage_event = event_profile("marriage")
marriage_event.setDate(1930, 6, 1)
all_events.append(marriage_event)
death_event = event_profile("death")
death_event.setDate(1970, 1, 1)
all_events.append(death_event)
burial_event = event_profile("burial")
burial_event.setDate(1970, 1, 2)
all_events.append(burial_event)

#This function will provide a True if the dates are consistent (i.e. your are not getting baptised before being born of after dying)
checkDateConsistency(all_events)

#This function will provide the best date, taking 2 dates. In the following case, it will take reisdence date as being more accurate
getBestDate(date(1910, 2, 1), "AFTER", date(1910, 5, 1), "EXACT")

GENERIC_PLACE_STRING = "Portillo,Valladolid,Castile and Leon,Spain"
#This function provides a generic location in standard location format. It is using MAPBOX API in behind
get_formatted_location(GENERIC_PLACE_STRING)

my_name = "John Smith"
#It splits a given name into the name and surname. It checks the data with a database of names and surnames.
name, surname = get_name_surname_from_complete_name(my_name, language="en")
 def setLocation(self, location, language="en"):
     '''
     This function will introduce the location related to each event
     '''
     location_data = get_formatted_location(location)
     self.location = location_data
This example will show how to use several  common genealogical tools that can be used.

All these functionalities are independent of the rest of the code
'''
from pyGenealogy.gen_utils import checkDateConsistency, getBestDate, get_formatted_location, get_name_surname_from_complete_name
from datetime import date

birth_date = date(1900,1,1)
residence_date = date(1910,1,1)
baptism_date = date(1901,1,12)
marriage_date = date(1930,6,1)
death_date = date(1970,1,1)
burial_date = date(1970,1,2)

#This function will provide a True if the dates are consistent (i.e. your are not getting baptised before being born of after dying)
checkDateConsistency(birth_date, residence_date, baptism_date, marriage_date, death_date, burial_date,
                         accuracy_birth = "EXACT", accuracy_residence = "EXACT", accuracy_baptism = "EXACT",
                         accuracy_marriage = "EXACT", accuracy_death = "EXACT", accuracy_burial = "EXACT")



#This function will provide the best date, taking 2 dates. In the following case, it will take reisdence date as being more accurate
getBestDate(birth_date, "AFTER", residence_date, "EXACT")

GENERIC_PLACE_STRING = "Portillo,Valladolid,Castile and Leon,Spain"
#This function provides a generic location in standard location format. It is using google maps API in behind
get_formatted_location(GENERIC_PLACE_STRING, language="en")

my_name = "John Smith"
#It splits a given name into the name and surname. It checks the data with a database of names and surnames.
name, surname = get_name_surname_from_complete_name(my_name, language = "en")