- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Feat/blueprint create #192
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            25 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      50cf43d
              
                Fix tests & other
              
              
                SpliiT 7801d91
              
                feat(NewBlueprint): New blueprint_create
              
              
                SpliiT cb2c549
              
                feat(NewBlueprint): New blueprint_create
              
              
                SpliiT 65517a8
              
                Apply prepare changes
              
              
                SpliiT 1dece19
              
                fix mypy & other comments
              
              
                SpliiT 21f4cb2
              
                fix mypy & other comments
              
              
                SpliiT d2a53df
              
                rm create_point from src/routes/schemas
              
              
                SpliiT 9a1cade
              
                feat(api): global error handling & direct response usage in create en…
              
              
                SpliiT 0a6b95f
              
                change typage
              
              
                SpliiT ffa5114
              
                rm type ignore
              
              
                SpliiT ab3da30
              
                change logic into class
              
              
                SpliiT 6d1ac42
              
                Merge branch 'next' into feat/blueprint_create
              
              
                SpliiT de811b8
              
                Apply prepare changes
              
              
                SpliiT 9e8d185
              
                fix versions
              
              
                SpliiT ade9566
              
                Merge branch 'next' into feat/blueprint_create
              
              
                SpliiT f77e7f6
              
                Apply prepare changes
              
              
                SpliiT 764929b
              
                wip
              
              
                SpliiT 062067c
              
                Merge branch 'feat/blueprint_create' of https://github.com/Geode-solu…
              
              
                SpliiT 50e69f6
              
                Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
              
              
                SpliiT e3a9444
              
                add data field
              
              
                SpliiT bd5d69d
              
                Apply prepare changes
              
              
                SpliiT 0e82d14
              
                rm ValueError
              
              
                SpliiT 3501a37
              
                Merge branch 'feat/blueprint_create' of https://github.com/Geode-solu…
              
              
                SpliiT 518bc0b
              
                Apply prepare changes
              
              
                SpliiT 47d03bf
              
                fix
              
              
                BotellaA 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
  
    
      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,54 @@ | ||
| # | ||
| # This file is autogenerated by pip-compile with Python 3.12 | ||
| # by the following command: | ||
| # | ||
| # pip-compile --cert=None --client-cert=None --index-url=None --pip-args=None requirements-internal.in | ||
| # | ||
| blinker==1.9.0 | ||
| # via | ||
| # flask | ||
| # opengeodeweb-microservice | ||
| click==8.3.0 | ||
| # via | ||
| # flask | ||
| # opengeodeweb-microservice | ||
| fastjsonschema==2.21.1 | ||
| # via opengeodeweb-microservice | ||
| flask==3.1.2 | ||
| # via | ||
| # flask-sqlalchemy | ||
| # opengeodeweb-microservice | ||
| flask-sqlalchemy==3.1.1 | ||
| # via opengeodeweb-microservice | ||
| greenlet==3.2.4 | ||
| # via | ||
| # opengeodeweb-microservice | ||
| # sqlalchemy | ||
| itsdangerous==2.2.0 | ||
| # via | ||
| # flask | ||
| # opengeodeweb-microservice | ||
| jinja2==3.1.6 | ||
| # via | ||
| # flask | ||
| # opengeodeweb-microservice | ||
| markupsafe==3.0.3 | ||
| # via | ||
| # flask | ||
| # jinja2 | ||
| # opengeodeweb-microservice | ||
| # werkzeug | ||
| opengeodeweb-microservice==1.0.3 | ||
| # via -r requirements-internal.in | ||
| sqlalchemy==2.0.43 | ||
| # via | ||
| # flask-sqlalchemy | ||
| # opengeodeweb-microservice | ||
| typing-extensions==4.15.0 | ||
| # via | ||
| # opengeodeweb-microservice | ||
| # sqlalchemy | ||
| werkzeug==3.1.3 | ||
| # via | ||
| # flask | ||
| # opengeodeweb-microservice | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
        
          
          
            129 changes: 129 additions & 0 deletions
          
          129 
        
  src/opengeodeweb_back/routes/create/blueprint_create.py
  
  
      
      
   
        
      
      
    
  
    
      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,129 @@ | ||
| # Standard library imports | ||
| import json | ||
| import os | ||
| import uuid | ||
| 
     | 
||
| # Third party imports | ||
| import flask | ||
| import opengeode | ||
| import werkzeug | ||
| 
     | 
||
| # Local application imports | ||
| from opengeodeweb_back import geode_functions, utils_functions | ||
| from opengeodeweb_microservice.database.data import Data | ||
| from opengeodeweb_microservice.database.connection import get_session | ||
| from opengeodeweb_back.utils_functions import save_all_viewables_and_return_info | ||
| 
     | 
||
| routes = flask.Blueprint("create", __name__, url_prefix="/opengeodeweb_back/create") | ||
| 
     | 
||
| schemas = os.path.join(os.path.dirname(__file__), "schemas") | ||
| 
     | 
||
| # Load schema for point creation | ||
| with open(os.path.join(schemas, "create_point.json"), "r") as file: | ||
| create_point_json = json.load(file) | ||
| 
     | 
||
| 
     | 
||
| @routes.route(create_point_json["route"], methods=create_point_json["methods"]) | ||
| def create_point(): | ||
                
      
                  SpliiT marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| """Endpoint to create a single point in 3D space.""" | ||
| print(f"create_point : {flask.request=}", flush=True) | ||
| 
     | 
||
| utils_functions.validate_request(flask.request, create_point_json) | ||
| 
     | 
||
| # Extract data from request | ||
| title = flask.request.json["title"] | ||
                
      
                  SpliiT marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| x = flask.request.json["x"] | ||
| y = flask.request.json["y"] | ||
| z = flask.request.json["z"] | ||
| 
     | 
||
| # Create the point set | ||
| class_ = geode_functions.geode_object_class("PointSet3D") | ||
| point_set = class_.create() | ||
| builder = geode_functions.create_builder("PointSet3D", point_set) | ||
| builder.create_point(opengeode.Point3D([x, y, z])) | ||
| builder.set_name(title) | ||
| 
     | 
||
| # Save and get info | ||
| result = save_all_viewables_and_return_info( | ||
| geode_object="PointSet3D", data=point_set, input_file=None, additional_files=[] | ||
                
      
                  SpliiT marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| ) | ||
| 
     | 
||
| # Prepare response with the title | ||
| response = { | ||
                
      
                  SpliiT marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| "viewable_file_name": result["viewable_file_name"], | ||
| "id": result["id"], | ||
| "name": title, | ||
| "native_file_name": result["native_file_name"], | ||
| "object_type": result["object_type"], | ||
| "geode_object": result["geode_object"], | ||
| } | ||
| 
     | 
||
| # Add binary_light_viewable if it exists | ||
| if "binary_light_viewable" in result: | ||
                
      
                  SpliiT marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| response["binary_light_viewable"] = result["binary_light_viewable"] | ||
| 
     | 
||
| return flask.make_response(response, 200) | ||
| 
     | 
||
| 
     | 
||
| # Load schema for AOI creation | ||
| with open(os.path.join(schemas, "create_aoi.json"), "r") as file: | ||
| create_aoi_json = json.load(file) | ||
| 
     | 
||
| 
     | 
||
| @routes.route(create_aoi_json["route"], methods=create_aoi_json["methods"]) | ||
| def create_aoi(): | ||
| """Endpoint to create an Area of Interest (AOI) as an EdgedCurve3D.""" | ||
| print(f"create_aoi : {flask.request=}", flush=True) | ||
| 
     | 
||
| utils_functions.validate_request(flask.request, create_aoi_json) | ||
| 
     | 
||
| # Extract data from request | ||
| name = flask.request.json["name"] | ||
| points = flask.request.json["points"] | ||
| z = flask.request.json["z"] | ||
| 
     | 
||
| # Create the edged curve | ||
| class_ = geode_functions.geode_object_class("EdgedCurve3D") | ||
| edged_curve = class_.create() | ||
| builder = geode_functions.create_builder("EdgedCurve3D", edged_curve) | ||
| builder.set_name(name) | ||
| 
     | 
||
| # Create vertices first | ||
| vertex_indices = [] | ||
| for point in points: | ||
| vertex_id = builder.create_point(opengeode.Point3D([point["x"], point["y"], z])) | ||
| vertex_indices.append(vertex_id) | ||
| 
     | 
||
| # Create edges between consecutive vertices and close the loop | ||
| num_vertices = len(vertex_indices) | ||
| for i in range(num_vertices): | ||
| edge_id = builder.create_edge() | ||
| next_i = (i + 1) % num_vertices # Wrap around to close the loop | ||
| builder.set_edge_vertex(opengeode.EdgeVertex(edge_id, 0), vertex_indices[i]) | ||
| builder.set_edge_vertex( | ||
| opengeode.EdgeVertex(edge_id, 1), vertex_indices[next_i] | ||
                
      
                  SpliiT marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| ) | ||
| 
     | 
||
| # Save and get info | ||
| result = save_all_viewables_and_return_info( | ||
| geode_object="EdgedCurve3D", | ||
| data=edged_curve, | ||
| input_file=None, | ||
| additional_files=[], | ||
| ) | ||
| 
     | 
||
| # Prepare response | ||
| response = { | ||
| "viewable_file_name": result["viewable_file_name"], | ||
| "id": result["id"], | ||
| "name": name, | ||
| "native_file_name": result["native_file_name"], | ||
| "object_type": result["object_type"], | ||
| "geode_object": result["geode_object"], | ||
| } | ||
| 
     | 
||
| # Add binary_light_viewable if it exists | ||
| if "binary_light_viewable" in result: | ||
| response["binary_light_viewable"] = result["binary_light_viewable"] | ||
| 
     | 
||
| return flask.make_response(response, 200) | ||
        
          
          
            46 changes: 46 additions & 0 deletions
          
          46 
        
  src/opengeodeweb_back/routes/create/schemas/create_aoi.json
  
  
      
      
   
        
      
      
    
  
    
      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,46 @@ | ||
| { | ||
| "route": "/create_aoi", | ||
| "methods": [ | ||
| "POST" | ||
| ], | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "description": "Name of the AOI" | ||
| }, | ||
| "points": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "x": { | ||
| "type": "number" | ||
| }, | ||
| "y": { | ||
| "type": "number" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "x", | ||
| "y" | ||
| ], | ||
| "additionalProperties": false | ||
| }, | ||
| "minItems": 4, | ||
| "maxItems": 4 | ||
| }, | ||
| "z": { | ||
| "type": "number" | ||
| }, | ||
| "id": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name", | ||
| "points", | ||
| "z" | ||
| ], | ||
| "additionalProperties": false | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.