-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MODE_BATCH incorrect city detection #16
Comments
Do you use the same DB version in both cases? |
Yeap, check this output to be sure: from pysyge.pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY
from pprint import pprint
geodata = GeoLocator('/tmp/SxGeoCity.dat', MODE_BATCH | MODE_MEMORY)
# print('DB version %s (%s)' % (geodata._db_ver, geodata._db_ts))
pprint(geodata._prolog) # added to class manually
geodata.get_location('109.252.119.71', detailed=True)
{'b_idx_len': 224,
'charset': 0,
'city_size': 2682917,
'country_size': 9387,
'db_items': 5994260,
'id_len': 3,
'm_idx_len': 1775,
'max_city': 127,
'max_country': 147,
'max_region': 175,
'pack_size': 157,
'range': 3376,
'region_size': 109379,
'ts': 1700171947,
'type': 3,
'ver': 22}
Out[4]:
{'country_id': 174,
'country_iso': 'PL',
'region_id': 3337499,
'city': 'Щецин',
'lon': 14.55302,
'lat': 53.42894,
'fips': '0',
'info': {'city': {'id': 3083829,
'lat': 53.42894,
'lon': 14.55302,
'name_ru': 'Щецин',
'name_en': 'Szczecin'},
'region': {'id': 3337499,
'name_ru': 'Западно-Поморское воеводство',
'name_en': 'Zachodniopomorskie',
'iso': 'PL-ZP'},
'country': {'id': 174,
'iso': 'PL',
'lat': 52.0,
'lon': 20.0,
'name_ru': 'Польша',
'name_en': 'Poland'}},
'region': 'Западно-Поморское воеводство',
'tz': ''} and for php: cat sxgeo_sample.php
<?php
chdir("/app/");
include("SxGeo.php");
$SxGeo = new SxGeo('SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY); // Самый производительный режим, если нужно обработать много IP за раз
$ip = '109.252.119.71';
print("IP: $ip\n");
var_export($SxGeo->info);
print("\n");
var_export($SxGeo->get($ip)); // Вся информация о городе docker run --rm -v $(pwd):/app/ php:7-cli php /app/sxgeo_sample.php
IP: 109.252.119.71
array (
'ver' => 22,
'time' => 1700171947,
'type' => 3,
'charset' => 0,
'b_idx_len' => 224,
'm_idx_len' => 1775,
'range' => 3376,
'db_items' => 5994260,
'id_len' => 3,
'max_region' => 175,
'max_city' => 127,
'region_size' => 109379,
'city_size' => 2682917,
'max_country' => 147,
'country_size' => 9387,
'pack_size' => 157,
'regions_begin' => 35973753,
'cities_begin' => 36083132,
)
array (
'city' =>
array (
'id' => 524901,
'lat' => 55.75222,
'lon' => 37.61556,
'name_ru' => 'Москва',
'name_en' => 'Moscow',
),
'country' =>
array (
'id' => 185,
'iso' => 'RU',
),
) |
Thank you for the report. |
MEMORY mode is broken. MODE_FILE gives us correct results (at least for '109.252.119.71') from pysyge.pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY
from pprint import pprint
geodata = GeoLocator('/tmp/SxGeoCity.dat', MODE_BATCH | MODE_MEMORY)
pprint(geodata.get_location('109.252.119.71', detailed=True))
{'city': 'Щецин',
'country_id': 174,
'country_iso': 'PL',
'fips': '0',
'info': {'city': {'id': 3083829,
'lat': 53.42894,
'lon': 14.55302,
'name_en': 'Szczecin',
'name_ru': 'Щецин'},
'country': {'id': 174,
'iso': 'PL',
'lat': 52.0,
'lon': 20.0,
'name_en': 'Poland',
'name_ru': 'Польша'},
'region': {'id': 3337499,
'iso': 'PL-ZP',
'name_en': 'Zachodniopomorskie',
'name_ru': 'Западно-Поморское воеводство'}},
'lat': 53.42894,
'lon': 14.55302,
'region': 'Западно-Поморское воеводство',
'region_id': 3337499,
'tz': ''}
from pysyge.pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY
from pprint import pprint
geodata = GeoLocator('/tmp/SxGeoCity.dat')
pprint(geodata.get_location('109.252.119.71', detailed=True))
{'city': 'Москва',
'country_id': 185,
'country_iso': 'RU',
'fips': '0',
'info': {'city': {'id': 524901,
'lat': 55.75222,
'lon': 37.61556,
'name_en': 'Moscow',
'name_ru': 'Москва'},
'country': {'id': 185,
'iso': 'RU',
'lat': 60.0,
'lon': 100.0,
'name_en': 'Russia',
'name_ru': 'Россия'},
'region': {'id': 524894,
'iso': 'RU-MOW',
'name_en': 'Moskva',
'name_ru': 'Москва'}},
'lat': 55.75222,
'lon': 37.61556,
'region': 'Москва',
'region_id': 524894,
'tz': ''} |
MODE_BATCH seems to be fixed in master now. |
Incorrect detection for some IPs. 109.252.119.71 as an example
PHP API:
PYSYGE
The text was updated successfully, but these errors were encountered: