import src.Constants.ProjectPaths
pp = src.Constants.ProjectPaths.ProjectPathsStore.DataSnapshots.value

railwaysPath = pp + "\\railwaysSnapshot20190128.json"
stationsPath = pp + "\\stationsSnapshot20190128.json"

import src.JSONTool as jst

railways = jst.JSONDeserialize(railwaysPath)
stations = jst.JSONDeserialize(stationsPath)

for r in railways:
    num = int(r['Number'])
    for s in stations:
        for location in s['WMSData']['LocationPoints']:
            print(s['Name'], location)
Ejemplo n.º 2
0
railwaysPath = pp + "\\railwaysSnapshot20190128.json"
stationsPath = pp + "\\stationsSnapshot20190128.json"

#^^^PATHS UP HERE^^^

import Reports.ReportMergedRailways as railwaysSource
import Reports.ReportMergedStations as stationsSource

railways = railwaysSource.returnMergedRailways()
stations = stationsSource.returnMergedStations()

import src.Constants.ProjectPaths
pp = src.Constants.ProjectPaths.ProjectPathsStore.DataSnapshots.value

import src.JSONTool as jst

jst.JSONSerialize(stations, stationsPath)
jst.JSONSerialize(railways, railwaysPath)

import Reports.Datasets.Railways_Dataset as Source_Railways
import Reports.Datasets.RailwayUnits_Dataset as Source_RailwayUnits
import Reports.Datasets.Stations_Dataset as Source_Stations

Railways_Geometries = Source_Railways.ReturnGeometriesPartialDataset()
RailwayUnits_Geometries = Source_RailwayUnits.ReturnGeometriesPartialDataset()
Stations_Geometries = Source_Stations.ReturnGeometriesPartialDataset()

for r in Railways_Geometries:
    r['Value'] = 'LINESTRING(' + r['Value'] + ')'

for u in RailwayUnits_Geometries:
    u['Value'] = 'MULTIPOLYGON(((' + u['Value'] + ')))'

for s in Stations_Geometries:
    s['Value'] = 'POINT(' + s['Value'] + ')'

Geometries_Dataset = RailwayUnits_Geometries + Railways_Geometries + Stations_Geometries

for row in Geometries_Dataset:
    row['Value'] = row['Value'].replace(',', '#')
    row['Value'] = row['Value'].replace(' ', ',')
    row['Value'] = row['Value'].replace('#', ' ')

import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\Geometries_Dataset.json'

jst.JSONSerialize(Geometries_Dataset, path)
print("serialising done - geometries")
TypesOfAPoint_Dataset = []

index = 1

for t in Hashset:
    SingleType = dict()
    SingleType['Id'] = index
    SingleType['AbbreviatedName'] = t

    TypesOfAPoint_Dataset.append(SingleType)

    index += 1


def ReturnTypesOfAPointDataset():
    return TypesOfAPoint_Dataset


def ReturnHashtableNamesToIds():
    Hashtable = dict()
    for t in TypesOfAPoint_Dataset:
        Hashtable[t['AbbreviatedName']] = t['Id']

    return Hashtable


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\TypesOfAPoint_Dataset.json'

jst.JSONSerialize(TypesOfAPoint_Dataset, path)
print("serialising done - types of a point")
Ejemplo n.º 5
0
import DataReaders.wwwReaders.wwwReader as SourceOfRollingStock
RawRollingStock = SourceOfRollingStock.returnRollingStockList()

RollingStock_Dataset = []

for r in RawRollingStock:
    car = dict()
    car['Id'] = r['Id']
    car['OwnerId'] = r['OwnerId']
    car['Name'] = r['Name']

    RollingStock_Dataset.append(car)


def ReturnRollingStockDataset():
    return RollingStock_Dataset


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\RollingStock_Dataset.json'

jst.JSONSerialize(RollingStock_Dataset, path)
print("serialising done")
import DataReaders.wwwReaders.wwwReader as SourceOwners
OwnersRaw = SourceOwners.ownersDBList

Owners_Dataset = []

for o in OwnersRaw:
    owner = dict()
    owner['Id'] = o['Id']
    owner['Name'] = o['Name']

    Owners_Dataset.append(owner)

def ReturnOwnersDataset():
    return Owners_Dataset

import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\Owners_Dataset.json'

jst.JSONSerialize(Owners_Dataset, path)
print("serialising done")
Ejemplo n.º 7
0
def GetStationsSnapshot_List():
    stations = jst.JSONDeserialize(stationsPath)
    return stations


import DataReaders.wwwReaders.wwwReader as SourceOfPhotosToObjects
PhotosToObjectsRaw = SourceOfPhotosToObjects.returnPhotosToObjectsList()

PhotosToObjects_Dataset = []

for pto in PhotosToObjectsRaw:
    photoToObject = dict()
    photoToObject['Id'] = pto['Id']
    photoToObject['PhotoId'] = pto['PhotoId']
    photoToObject['ObjectId'] = pto['ObjectId']

    PhotosToObjects_Dataset.append(photoToObject)

def ReturnPhotosToObjectsDataset():
    return PhotosToObjects_Dataset

import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\PhotosToObjects_Dataset.json'

jst.JSONSerialize(PhotosToObjects_Dataset, path)
print("serialising done - photos to objects")


Ejemplo n.º 9
0
def GetRailwaysSnapshot_List():
    railways = jst.JSONDeserialize(railwaysPath)
    return railways
Ejemplo n.º 10
0
            new['GeometryId'] = None
        else:
            new['GeometryId'] = index

            geometry = dict()
            geometry['Id'] = index
            geometry['Value'] = r['Geometry']
            index += 1

        Railways_Dataset.append(new)
        if (geometry is not None):
            Geometries_Partial_Dataset.append(geometry)
        geometry = None


ProcessDatasets()


def ReturnRailwaysDataset():
    return Railways_Dataset


def ReturnGeometriesPartialDataset():
    return Geometries_Partial_Dataset


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\Railways_Dataset.json'

jst.JSONSerialize(Railways_Dataset, path)
print("serialising done")
import DataReaders.wwwReaders.wwwReader as SourceOfPhotos
PhotosRaw = SourceOfPhotos.returnPhotosList()

Photos_Dataset = []

for p in PhotosRaw:
    photo = dict()
    photo['Id'] = p['Id']
    photo['AdditionDateTime'] = p['AdditionDateTime']
    photo['FilePath'] = p['FilePath']
    photo['Description'] = p['Description']

    Photos_Dataset.append(photo)


def ReturnPhotosDataset():
    return Photos_Dataset


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\Photos_Dataset.json'

jst.JSONSerialize(Photos_Dataset, path)
print("serialising done - photos")
Ejemplo n.º 12
0
        rel['RailwayId'] = int(r['LineId'])
        rel['GeometriesId'] = None

        Relationships_Dataset.append(rel)

        index_relationships += 1

print('done so far')
#TODO
#process each station and create full relations list


def ReturnGeometriesPartialDataset():
    return Geometries_Dataset


def ReturnStationsDataset():
    return Stations_Dataset


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\Stations_Dataset.json'

jst.JSONSerialize(Stations_Dataset, path)

path_relations = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\StationsToGeometries_Dataset.json'

jst.JSONSerialize(Relationships_Dataset, path_relations)

print("serialising done - stations")
for u in Units_Raw:

    unit = dict()
    unit['Id'] = index
    unit['Name'] = u['ZAKLAD']
    unit['GeometriesId'] = index

    Units_Dataset.append(unit)

    geometry = dict()
    geometry['Id'] = index
    geometry['Value'] = u['GEOM']

    Geometries_Partial_Dataset.append(geometry)

    index += 1


def ReturnUnitsDataset():
    return Units_Dataset


def ReturnGeometriesPartialDataset():
    return Geometries_Partial_Dataset


import src.JSONTool as jst
path = 'C:\\Users\\Dell\\source\\repos\\MalopolskaRailNetwork\\MalopolskaRailNetwork\\Data\\DataSnapshots\\FinalDatasets\\RailwayUnits_Dataset.json'

jst.JSONSerialize(Units_Dataset, path)
print("serialising done")