mirror of https://gitlab.com/bashrc2/epicyon
Geolocations using city size
parent
9227b49eb7
commit
9b71708649
18
city.py
18
city.py
|
@ -138,7 +138,7 @@ def spoofGeolocation(baseDir: str,
|
||||||
locationsFilename = baseDir + '/custom_locations.txt'
|
locationsFilename = baseDir + '/custom_locations.txt'
|
||||||
if not os.path.isfile(locationsFilename):
|
if not os.path.isfile(locationsFilename):
|
||||||
locationsFilename = baseDir + '/locations.txt'
|
locationsFilename = baseDir + '/locations.txt'
|
||||||
cityRadius = 0.1
|
manCityRadius = 0.1
|
||||||
varianceAtLocation = 0.0004
|
varianceAtLocation = 0.0004
|
||||||
default_latitude = 51.8744
|
default_latitude = 51.8744
|
||||||
default_longitude = 0.368333
|
default_longitude = 0.368333
|
||||||
|
@ -159,8 +159,12 @@ def spoofGeolocation(baseDir: str,
|
||||||
city = city.lower()
|
city = city.lower()
|
||||||
for cityName in cities:
|
for cityName in cities:
|
||||||
if city in cityName.lower():
|
if city in cityName.lower():
|
||||||
latitude = cityName.split(':')[1]
|
cityFields = cityName.split(':')
|
||||||
longitude = cityName.split(':')[2]
|
latitude = cityFields[1]
|
||||||
|
longitude = cityFields[2]
|
||||||
|
areaKm2 = 0
|
||||||
|
if len(cityFields) > 3:
|
||||||
|
areaKm2 = int(cityFields[3])
|
||||||
latdirection = 'N'
|
latdirection = 'N'
|
||||||
longdirection = 'E'
|
longdirection = 'E'
|
||||||
if 'S' in latitude:
|
if 'S' in latitude:
|
||||||
|
@ -182,6 +186,14 @@ def spoofGeolocation(baseDir: str,
|
||||||
# patterns of activity change in the city over time
|
# patterns of activity change in the city over time
|
||||||
(distanceFromCityCenter, angleRadians) = \
|
(distanceFromCityCenter, angleRadians) = \
|
||||||
_getCityPulse(currTimeAdjusted, decoySeed)
|
_getCityPulse(currTimeAdjusted, decoySeed)
|
||||||
|
# The city radius value is in longitude and the reference
|
||||||
|
# is Manchester. Adjust for the radius of the chosen city.
|
||||||
|
if areaKm2 > 1:
|
||||||
|
manRadius = math.sqrt(630 / math.pi)
|
||||||
|
radius = math.sqrt(areaKm2 / math.pi)
|
||||||
|
cityRadius = manCityRadius * manRadius / radius
|
||||||
|
else:
|
||||||
|
cityRadius = manCityRadius
|
||||||
# Get the position within the city, with some randomness added
|
# Get the position within the city, with some randomness added
|
||||||
latitude += \
|
latitude += \
|
||||||
distanceFromCityCenter * cityRadius * math.cos(angleRadians)
|
distanceFromCityCenter * cityRadius * math.cos(angleRadians)
|
||||||
|
|
814
locations.txt
814
locations.txt
File diff suppressed because it is too large
Load Diff
26
tests.py
26
tests.py
|
@ -3600,20 +3600,21 @@ def testRemovePostInteractions() -> None:
|
||||||
def testSpoofGeolocation() -> None:
|
def testSpoofGeolocation() -> None:
|
||||||
print('testSpoofGeolocation')
|
print('testSpoofGeolocation')
|
||||||
citiesList = [
|
citiesList = [
|
||||||
'NEW YORK, USA:40.6397:W73.7789',
|
'NEW YORK, USA:40.7127281:W74.0060152:784',
|
||||||
'LOS ANGELES, USA:33.9425:W118.408',
|
'LOS ANGELES, USA:34.0536909:W118.242766:1214',
|
||||||
'HOUSTON, USA:29.9803:W95.3397',
|
'HOUSTON, USA:29.6072:W95.1586:1553',
|
||||||
'MANCHESTER, ENGLAND:53.4794892:W2.2451148'
|
'MANCHESTER, ENGLAND:53.4794892:W2.2451148:630',
|
||||||
|
'BERLIN, GERMANY:52.5170365:13.3888599:891'
|
||||||
]
|
]
|
||||||
currTime = datetime.datetime.utcnow()
|
currTime = datetime.datetime.utcnow()
|
||||||
decoySeed = 7634681
|
decoySeed = 7634681
|
||||||
cityRadius = 0.1
|
cityRadius = 0.1
|
||||||
coords = spoofGeolocation('', 'los angeles', currTime,
|
coords = spoofGeolocation('', 'los angeles', currTime,
|
||||||
decoySeed, citiesList)
|
decoySeed, citiesList)
|
||||||
assert coords[0] >= 33.9425 - cityRadius
|
assert coords[0] >= 34.0536909 - cityRadius
|
||||||
assert coords[0] <= 33.9425 + cityRadius
|
assert coords[0] <= 34.0536909 + cityRadius
|
||||||
assert coords[1] >= 118.408 - cityRadius
|
assert coords[1] >= 118.242766 - cityRadius
|
||||||
assert coords[1] <= 118.408 + cityRadius
|
assert coords[1] <= 118.242766 + cityRadius
|
||||||
assert coords[2] == 'N'
|
assert coords[2] == 'N'
|
||||||
assert coords[3] == 'W'
|
assert coords[3] == 'W'
|
||||||
assert len(coords[4]) > 4
|
assert len(coords[4]) > 4
|
||||||
|
@ -3642,12 +3643,17 @@ def testSpoofGeolocation() -> None:
|
||||||
currTime = datetime.datetime.strptime("2021-05-" + str(dayNumber) +
|
currTime = datetime.datetime.strptime("2021-05-" + str(dayNumber) +
|
||||||
" " + hourStr + ":14",
|
" " + hourStr + ":14",
|
||||||
"%Y-%m-%d %H:%M")
|
"%Y-%m-%d %H:%M")
|
||||||
coords = spoofGeolocation('', 'manchester, england', currTime,
|
coords = spoofGeolocation('', 'new york, usa', currTime,
|
||||||
decoySeed, citiesList)
|
decoySeed, citiesList)
|
||||||
|
#coords = spoofGeolocation('', 'berlin, germany', currTime,
|
||||||
|
# decoySeed, citiesList)
|
||||||
|
longitude = coords[1]
|
||||||
|
if coords[3] == 'W':
|
||||||
|
longitude = -coords[1]
|
||||||
kmlStr += '<Placemark id="' + str(i) + '">\n'
|
kmlStr += '<Placemark id="' + str(i) + '">\n'
|
||||||
kmlStr += ' <name>' + str(i) + '</name>\n'
|
kmlStr += ' <name>' + str(i) + '</name>\n'
|
||||||
kmlStr += ' <Point>\n'
|
kmlStr += ' <Point>\n'
|
||||||
kmlStr += ' <coordinates>' + str(-coords[1]) + ',' + \
|
kmlStr += ' <coordinates>' + str(longitude) + ',' + \
|
||||||
str(coords[0]) + ',0</coordinates>\n'
|
str(coords[0]) + ',0</coordinates>\n'
|
||||||
kmlStr += ' </Point>\n'
|
kmlStr += ' </Point>\n'
|
||||||
kmlStr += '</Placemark>\n'
|
kmlStr += '</Placemark>\n'
|
||||||
|
|
Loading…
Reference in New Issue