Skip to content

Commit 8c42e33

Browse files
committed
Clean up
1 parent 9e5f4d2 commit 8c42e33

8 files changed

Lines changed: 7 additions & 108 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ An example how to start the service using waitress.
185185
waitress-serve --listen="*:8080" --call "esdlvalidator.api.manage:create_app"
186186
```
187187

188-
### Update static ESDL metamodel code
188+
<!-- ### Deprecated: Update static ESDL metamodel code
189189
190190
To update the ESDL code to work with the latest version of the ESDL ecore model, update esdl.ecore to the latest version
191191
and run
192192
193193
```
194194
pip3 install pyecoregen
195195
pyecoregen -e esdl.ecore -o ./esdlvalidator/core/esdl
196-
```
196+
``` -->
197197

198198
## Docker
199199

dev.docker-compose.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker-compose-poc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ networks:
88

99
services:
1010
esdl-validator:
11-
# image: mvrijlandt/nwn_esdl_validator:0.0.4
1211
build: ./
1312
ports:
1413
- "5000:5000"
Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
import json
2-
import uuid
3-
import logging
4-
from datetime import datetime as dt
5-
from math import cos, sin, atan2, sqrt, radians, degrees
62

7-
from esdl import Notes, Line, Point, Polygon, Note
83
from flask import request, Response
94
from flask_restx import Resource
105

116
from esdlvalidator.api import app
127
from esdlvalidator.api.controller import validationService
138
from esdlvalidator.core.exceptions import SchemaNotFound
14-
from esdlvalidator.validation.functions import utils
159

1610
parser = app.api.parser()
1711
parser.add_argument("data", type=str, required=True)
18-
parser.add_argument("schemas", type=str, required=True)
12+
parser.add_argument("schemas", type=str, help="List of schema id's, comma separated", required=True)
1913

2014

2115
@app.ns_validation_to_msgs.route('/')
@@ -83,77 +77,3 @@ def set_messages(result, asset, msgs):
8377
return result
8478
result.append({"assetID": asset, "messages": msgs})
8579
return result
86-
87-
def update_esdl(self, resource, results: dict):
88-
asset_notes = {}
89-
now = dt.now()
90-
91-
notes = Notes()
92-
notes.id = str(uuid.uuid4())
93-
notes.name = "Validation Notes"
94-
95-
for schema in results['schemas']:
96-
for validation in schema['validations']:
97-
if "errors" in validation:
98-
for error in validation['errors']:
99-
if isinstance(error, dict):
100-
asset_id = error["offending_asset"]
101-
message = error["message"]
102-
if asset_id in asset_notes:
103-
note = asset_notes[asset_id]
104-
note.text = note.text + "\nERROR: {}".format(message)
105-
else:
106-
asset = resource.uuid_dict[asset_id]
107-
p = self.get_center_point(asset)
108-
note = Note(id=str(uuid.uuid4()), mapLocation=p, author="ESDLValidatorService",
109-
title=asset_id, text="ERROR: {}".format(message), date=now)
110-
asset_notes[asset_id] = note
111-
if "warnings" in validation:
112-
for warning in validation['warnings']:
113-
if isinstance(warning, dict):
114-
asset_id = warning["offending_asset"]
115-
message = warning["message"]
116-
if asset_id in asset_notes:
117-
note = asset_notes[asset_id]
118-
note.text = note.text + "\nWARNING: {}".format(message)
119-
else:
120-
asset = resource.uuid_dict[asset_id]
121-
p = self.get_center_point(asset)
122-
note = Note(id=str(uuid.uuid4()), mapLocation=p, author="ESDLValidatorService",
123-
title=asset_id, text="WARNING: {}".format(message), date=now)
124-
asset_notes[asset_id] = note
125-
for n in asset_notes.values():
126-
notes.note.append(n)
127-
128-
return notes
129-
130-
@staticmethod
131-
def get_center_point(asset):
132-
a = asset
133-
while not utils.has_attribute(a, 'geometry'):
134-
a = a.eContainer()
135-
geometry = a.geometry
136-
points = None
137-
if isinstance(geometry, Polygon):
138-
points = geometry.exterior[0:2]
139-
elif isinstance(geometry, Line):
140-
points = geometry.point[0:2]
141-
elif isinstance(geometry, Point):
142-
points = [geometry]
143-
x = []
144-
y = []
145-
z = []
146-
for p in points:
147-
x.append(cos(radians(p.lat)) * cos(radians(p.lon)))
148-
y.append(cos(radians(p.lat)) * sin(radians(p.lon)))
149-
z.append(sin(radians(p.lat)))
150-
151-
x_avg = (sum(x) / len(x))
152-
y_avg = (sum(y) / len(y))
153-
z_avg = (sum(z) / len(z))
154-
155-
lon = atan2(y_avg, x_avg)
156-
hyp = sqrt(x_avg * x_avg + y_avg * y_avg)
157-
lat = atan2(z_avg, hyp)
158-
159-
return Point(lat=degrees(lat), lon=degrees(lon))

esdlvalidator/validation/functions/check_multi_cond_xor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from esdlvalidator.validation.functions.function import FunctionFactory, FunctionCheck, FunctionDefinition, \
44
ArgDefinition, FunctionType, CheckResult
55

6-
76
@FunctionFactory.register(FunctionType.CHECK, "multi_cond_xor")
87
class ContainsMultiConditionCheck(FunctionCheck):
98

@@ -49,7 +48,6 @@ def execute(self):
4948
return CheckResult(False, msg)
5049
else:
5150
return CheckResult(False, result)
52-
# print(str(utils.get_attribute(self.value, p)), p, v)
5351
if utils.get_attribute(self.value, p) == v:
5452
fails += 1
5553

esdlvalidator/validation/validator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class EsdlValidator:
2020
def __init__(self):
2121
pass
2222

23-
def validate(self, esdl, schemas: list):
23+
def validate(self, esdl, schemas: list) -> ValidatorResult:
2424
"""Validate an ESDL against one or more multiple schemas
2525
2626
Args:
2727
esdl (object): The loaded ESDL
28+
schemas (list): A list of validation schemas
2829
2930
Returns:
3031
result: ValidatorResult containing the validation results

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pyecore>=0.11.6
2-
pyecoregen>=0.4.3
2+
pyecoregen>=0.5.0
33
lxml>=4.6.2
44
numpy>=1.19.4
55
flask>=1.1.2
@@ -27,4 +27,4 @@ six>=1.15.0
2727
jsonschema>=3.2.0
2828
pyrsistent>=0.17.3
2929
pycodestyle>=2.6.0
30-
pyESDL>=21.9.1
30+
pyESDL>=25.7

updateESDL.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)