--- a/alueet.py Fri May 19 21:15:12 2017 +0300 +++ b/alueet.py Thu May 25 16:41:21 2017 +0300 @@ -1,12 +1,7 @@ #!/usr/bin/env python3 -from pprint import pprint -from PyQt5.QtCore import QPointF, Qt -from PyQt5.QtGui import QPolygonF -from PyQt5.QtWidgets import QApplication import sys, json from misc import * - -app = QApplication(sys.argv) +from geometria import * with open('alueet.gmp') as file: data = file.read().split('@') @@ -18,7 +13,7 @@ with open('gtfs/stops.txt') as file: for rivi in lue_csv(file): - sijainti = QPointF(float(rivi['stop_lat']), float(rivi['stop_lon'])) + sijainti = Sijainti(float(rivi['stop_lat']), float(rivi['stop_lon'])) tunniste = rivi['stop_id'] pysäkit[tunniste] = sijainti @@ -28,8 +23,8 @@ coordinates = [] for point in polygon[3].split('~'): x, y = point.split(',') - coordinates.append(QPointF(float(x), float(y))) - district_shapes.append(QPolygonF(coordinates)) + coordinates.append(Sijainti(float(x), float(y))) + district_shapes.append(Monikulmio(*coordinates)) districts = {} bus_stop_districts = {} @@ -38,7 +33,7 @@ if stop_id is None: continue for district_shape in district_shapes: - if district_shape.containsPoint(pysäkit[stop_id], Qt.OddEvenFill): + if district_shape.sisältää_pisteen(pysäkit[stop_id]): assert name not in districts districts[name] = district_shape district_shapes.remove(district_shape) @@ -49,7 +44,7 @@ for stop_id, stop_position in pysäkit.items(): for district, shape in districts.items(): - if shape.containsPoint(stop_position, Qt.OddEvenFill): + if shape.sisältää_pisteen(stop_position): bus_stop_districts[stop_id] = district break else: @@ -58,5 +53,4 @@ covered = sum(int(bool(k)) for k in bus_stop_districts.values()) total = len(pysäkit) print('%.1f%% bus stops covered.' % (covered * 100 / total), file = sys.stderr) - json.dump(bus_stop_districts, sys.stdout, indent = 2)