-
Notifications
You must be signed in to change notification settings - Fork 1
Initial work #1
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
Open
Knight0132
wants to merge
10
commits into
IndoorSpatial:main
Choose a base branch
from
Knight0132:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Initial work #1
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9be8b41
Add new serialization modules and tests
Knight0132 a85e20a
Update serialization and test modifications, remove unused __init__
Knight0132 045b595
add test for serialization
Knight0132 b09fa0f
spilt all classes into different files
Knight0132 36e9684
modify the test for seiralization and deserialization, and then simpl…
Knight0132 3c5526d
modify the test and delete some wrong files
Knight0132 87a7ccf
add the function of visualization for graph and hypergraph
Knight0132 f6924da
add the visualization of connectionPoint and rlines
Knight0132 bc2be73
modify the visualization
Knight0132 3f98886
simplify visualization
Knight0132 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| """ | ||
| File Name: test_create.py | ||
|
|
||
| Copyright (c) 2023 - 2024 IndoorJson | ||
|
|
||
| Author: Ziwei Xiang <knightzz1016@gmail.com> | ||
| Create Date: 2024/3/14 | ||
| """ | ||
|
|
||
| import json | ||
| from shapely.wkt import loads | ||
|
Knight0132 marked this conversation as resolved.
Outdated
|
||
| import sys | ||
| import os | ||
|
|
||
| sys.path.append(os.path.abspath('../src')) | ||
|
|
||
| from serialization import Graph | ||
|
|
||
| graph = Graph() | ||
|
|
||
| properties = { | ||
| "name": "indoorjson3-python", | ||
| "labels": ["indoorgml", "GIS"], | ||
| "language": ["English", "中文", "한국어"], | ||
| "author": {"name": "Ziwei Xiang", "email": "knightzz1016@gmail.com"} | ||
| } | ||
|
|
||
| cells = [] | ||
|
|
||
| c1_id = "c1" | ||
| c1_properties = {"roomNumber": "1101"} | ||
| c1_space = loads("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))") | ||
| c1_node = loads("POINT (0.5 0.5)") | ||
| cell1 = graph.Cell(c1_id, c1_properties, c1_space, c1_node) | ||
| cells.append(cell1) | ||
|
|
||
| c2_id = "c2" | ||
| c2_properties = {"roomNumber": "1102"} | ||
| c2_space = loads("POLYGON ((1 0, 2 0, 2 1, 1 1, 1 0))") | ||
| c2_node = loads("POINT (1.5 0.5)") | ||
| cell2 = graph.Cell(c2_id, c2_properties, c2_space, c2_node) | ||
| cells.append(cell2) | ||
|
|
||
| c3_id = "c3" | ||
| c3_properties = {"roomNumber": "1103"} | ||
| c3_space = loads("POLYGON ((0 1, 1 1, 1 2, 0 2, 0 1))") | ||
| c3_node = loads("POINT (0.5 1.5)") | ||
| cell3 = graph.Cell(c3_id, c3_properties, c3_space, c3_node) | ||
| cells.append(cell3) | ||
|
|
||
| for cell in cells: | ||
| graph.add_cell(cell) | ||
|
|
||
| connections = [] | ||
|
|
||
| con1_id = "conn1-2" | ||
| con1_properties = {"type": "door", "开放时间": "全天", "오픈 시간": "하루 종일"} | ||
| con1_fr = c1_id | ||
| con1_to = c2_id | ||
| con1_bound = loads("LINESTRING (1 0, 1 1)") | ||
| con1_edge = loads("LINESTRING (0.5 0.5, 1.5 0.5)") | ||
| connection1 = graph.Connection(con1_id, con1_properties, con1_fr, con1_to, con1_bound, con1_edge) | ||
| connections.append(connection1) | ||
|
|
||
| con2_id = "conn3-1" | ||
| con2_properties = {"type": "window"} | ||
| con2_fr = c3_id | ||
| con2_to = c1_id | ||
| con2_bound = loads("LINESTRING (1 0, 1 1)") | ||
| con2_edge = loads("LINESTRING (0.5 0.5, 1.5 0.5)") | ||
| connection2 = graph.Connection(con2_id, con2_properties, con2_fr, con2_to, con2_bound, con2_edge) | ||
| connections.append(connection2) | ||
|
|
||
| for connection in connections: | ||
| graph.add_connection(connection) | ||
|
|
||
| layer_id = "layer" | ||
| layer_cells = [cell.id for cell in cells] | ||
| layer = graph.Layer(layer_id, layer_cells) | ||
| graph.set_layers(layer) | ||
|
|
||
| hypergraph = graph.get_hypergraph() | ||
| for hyperEdge in hypergraph['hyperEdges']: | ||
| i = 0 | ||
| if hyperEdge["inner_nodeset"]["ins"] and hyperEdge["inner_nodeset"]["outs"]: | ||
| i += 1 | ||
| rlines_id = str("rlines") + str(i) | ||
| rlines_cell = hyperEdge["id"] | ||
| rlines_ins = hyperEdge["inner_nodeset"]["ins"] | ||
| rlines_outs = hyperEdge["inner_nodeset"]["outs"] | ||
| rlines_closure = [] | ||
| rlines = graph.Rlines(rlines_id, rlines_cell, rlines_ins, rlines_outs, rlines_closure) | ||
| graph.set_rlineses(rlines) | ||
|
|
||
| with open('test_created.json', 'w', encoding='utf-8') as f: | ||
| json.dump(graph.to_json(), f, indent=4) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why there are no "assert" or "expect" in your test code? |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| { | ||
| "properties": [], | ||
| "cells": [ | ||
| { | ||
| "$id": "c1", | ||
| "properties": { | ||
| "roomNumber": "1101" | ||
| }, | ||
| "space": "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", | ||
| "node": "POINT (0.5 0.5)" | ||
| }, | ||
| { | ||
| "$id": "c2", | ||
| "properties": { | ||
| "roomNumber": "1102" | ||
| }, | ||
| "space": "POLYGON ((1 0, 2 0, 2 1, 1 1, 1 0))", | ||
| "node": "POINT (1.5 0.5)" | ||
| }, | ||
| { | ||
| "$id": "c3", | ||
| "properties": { | ||
| "roomNumber": "1103" | ||
| }, | ||
| "space": "POLYGON ((0 1, 1 1, 1 2, 0 2, 0 1))", | ||
| "node": "POINT (0.5 1.5)" | ||
| } | ||
| ], | ||
| "connections": [ | ||
| { | ||
| "$id": "conn1-2", | ||
| "properties": { | ||
| "type": "door", | ||
| "\u5f00\u653e\u65f6\u95f4": "\u5168\u5929", | ||
| "\uc624\ud508 \uc2dc\uac04": "\ud558\ub8e8 \uc885\uc77c" | ||
| }, | ||
| "source": "c1", | ||
| "target": "c2", | ||
| "bound": "LINESTRING (1 0, 1 1)", | ||
| "edge": "LINESTRING (0.5 0.5, 1.5 0.5)" | ||
| }, | ||
| { | ||
| "$id": "conn3-1", | ||
| "properties": { | ||
| "type": "window" | ||
| }, | ||
| "source": "c3", | ||
| "target": "c1", | ||
| "bound": "LINESTRING (1 0, 1 1)", | ||
| "edge": "LINESTRING (0.5 0.5, 1.5 0.5)" | ||
| } | ||
| ], | ||
| "layers": [ | ||
| { | ||
| "$id": "layer", | ||
| "cells": [ | ||
| "c1", | ||
| "c2", | ||
| "c3" | ||
| ] | ||
| } | ||
| ], | ||
| "rlineses": [ | ||
| { | ||
| "$id": "rlines1", | ||
| "cells": "c1", | ||
| "ins": [ | ||
| "conn3-1" | ||
| ], | ||
| "outs": [ | ||
| "conn1-2" | ||
| ], | ||
| "closure": [] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.