Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 0 additions & 135 deletions functions/texttostreet.py

This file was deleted.

2 changes: 0 additions & 2 deletions functions/prompt_bot.txt → prompt_bot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,3 @@ For example, if a user says "show me a street with trains, sidewalks, trees and
```

The output of this JSON representing a street's cross-section is extruded 150 meters, and additional street props and/or vehicle and pedestrian models are placed along each segment's extruded plane to generate a low fidelity realtime rendering of a 3D street scene that is navigable or editable by the user making the original request.

A final segment should exist with a `width` of 0, `type` "suggestion", and variantString to consist of a few sentences in plain language to suggest safer street treatments including but not limited to adding protected concrete barriers or bollards to protect vulnerable road users such as pedestrians vs. motor vehicles of curb weight great than 1,000 lbs.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
discord.py==2.0.1
python-dotenv==0.20.0
openai
firebase_functions
flask
33 changes: 33 additions & 0 deletions simple-server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from flask import Flask, render_template, request, redirect
from texttostreet import get_streetmix_json
import urllib.parse

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def form():
return render_template('form.html')

@app.route('/querytext', methods=['GET', 'POST'])
def querytext():
user_query = request.form['query']
if user_query:
streetmix_json = get_streetmix_json(user_query)
#return render_template('localhost:7001/index-bot.html', street_json=streetmix_json)
localhost_url = 'http://localhost:7001/index-bot.html'
street_url = "{localhost}#streetmix-json:{streetmix_json}".format(
localhost=localhost_url,
streetmix_json=urllib.parse.quote(streetmix_json)
)
return redirect(street_url)

@app.route('/json_street', methods=['GET', 'POST'])
def json_street():
user_query = request.form['query']
if user_query:
streetmix_json = get_streetmix_json(user_query)
return streetmix_json


if __name__ == "__main__":
app.run()
159 changes: 159 additions & 0 deletions streetmix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"properties": {
"name": {
"type": "string",
"description": "name of created street",
"default": "default street"
},
"data": {
"type": "object",
"properties": {
"street": {
"type": "object",
"properties": {
"rightBuildingVariant": {
"type": "string",
"description": "A string to determine which building variant to create for the right side of the street. Can use only provided variants from enum array",
"enum": [
"grass",
"narrow",
"residental",
"fence",
"parking-lot",
"waterfront",
"wide"
],
"default": "grass"
},
"leftBuildingVariant": {
"type": "string",
"description": "A string to determine which building variant to create for the left side of the street. Can use only provided variants from enum array",
"enum": [
"grass",
"narrow",
"residental",
"fence",
"parking-lot",
"waterfront",
"wide"
],
"default": "grass"
},
"width": {
"type": "number",
"description": "street width in imperial feet units. This is the sum of the width values of all segments"
},
"segments": {
"type": "array",
"description": "list of segments of a cross-section perspective of the 3D scene, each with a width in imperial feet units, a type in string format, and a variantString that applies modifications to the segment type",
"items": {
"type": "object",
"properties": {
"width": {
"type": "number",
"description": "segment width in imperial feet units. Here is minimal width for each type of segment: {'sidewalk-tree': 4, 'sidewalk-bike-rack': 5, 'sidewalk-bench': 4, 'sidewalk-wayfinding': 4, 'sidewalk-lamp': 4, 'bus-lane': 12, 'drive-lane': 10, 'light-rail': 12, 'streetcar': 12, 'turn-lane': 10, 'divider': 2, 'stencils': 12, 'food-truck': 10, 'flex-zone': 7, 'parking-lane': 7 for inbound and outbound variantString and 14 for other variants}",
"default": 9
},
"variantString": {
"type": "string",
"oneOf": [
{
"items": {
"enum": ["inbound|car","outbound|car"],
"description": "variants for drive-lane segments"
}
},
{
"items": {
"enum": ["empty", "sparse", "normal", "dense"],
"description": "variants for sidewalks segments. Default is 'normal'"
}
},
{
"items": {
"enum": ["right|modern","both|modern", "left|modern", "right|traditional", "both|traditional", "left|traditional", "right|pride", "both|pride", "left|pride"],
"description": "variants for sidewalk-lamp segments. Default is 'both|traditional'"
}
},
{
"items": {
"enum": ["left", "right"],
"description": "variants for utilities segments. Default is 'normal'"
}
},
{
"items": {
"enum": ["left", "right", "left-right-straight", "shared", "both", "left-straight", "right-straight", "straight"],
"description": "variants for turn-lane segments"
}
},
{
"items": {
"enum": ["big", "palm-tree"],
"description": "variants for sidewalk-tree segments"
}
},
{
"items": {
"enum": ["sideways|right", "sideways|left", "inbound|right", "inbound|left", "outbound|left", "outbound|right", "angled-front-left|left", "angled-front-right|left", "angled-rear-left|left", "angled-rear-right|left", "angled-front-left|right", "angled-front-right|right", "angled-rear-left|right", "angled-rear-right|right"],
"description": "variants for parking-lane segments"
}
}
],
"description": "Variant of segment. It's required propery. List of possible variants depend upon which segment type is selected. variantString values are separated with their subvariants by a pipe character (literally '|'). Drive-lane segments possible variants: 'inbound|car' (default variant) or 'outbound|car'. Most of drive-lane segments have a car subvariant by default. Sidewalk segments possible variants: empty/sparse/normal/dense variants, depends on pedestrian count, default is normal. Sidewalk could have a lamps (sidewalk-lamp type of segment), variants: right, left, both; and subvariants (through |): modern, traditional, pride. For example and by default 'right|modern'. Turn lane (turn-lane segment type) variants: left, right, left-right-straight, shared, both, left-straight, right-straight, straight. Sidewalk tree variants: palm-tree, big. Parking-lane variants: sideways (subvariants right,left), inbound or outbound (subvariants right,left), angled-front-left (angled front left), angled-front-right (angled front right), angled-rear-left (angled rear left), angled-rear-right (angled rear right)."
},
"type": {
"type": "string",
"description": "street segment type. Using default width for each segment from streetmix API. Use default variant for each type of segment",
"enum": [
"sidewalk",
"bus-lane",
"drive-lane",
"light-rail",
"streetcar",
"turn-lane",
"divider",
"temporary",
"stencils",
"food-truck",
"flex-zone",
"sidewalk-wayfinding",
"sidewalk-bench",
"sidewalk-bike-rack",
"magic-carpet",
"outdoor-dining",
"parklet",
"bikeshare",
"utilities",
"sidewalk-tree",
"sidewalk-lamp",
"transit-shelter",
"parking-lane"
],
"default": "sidewalk"
},
"elevation": {
"type": "number",
"description": "elevation level for segment. 1 is default for all type of sidewalks and buildings, 0 is default for roads, lanes, parking, etc",
"enum": [
0,
1
],
"default": 1
}
},
"required": [
"variantString", "type", "width"
]
}
}
}
}
}
}
},
"required": [
"data"
],
"type": "object"
}
43 changes: 43 additions & 0 deletions templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Python form submission example</title>
<style>
form {
width: 420px;
}

div {
margin-bottom: 20px;
}

textarea {
width: 100%;
height: 100px;
}

label {
display: inline-block;
width: 240px;
text-align: right;
padding-right: 10px;
}

button, input {
float: right;
}
</style>
</head>
<body>
<form method="post" action="{{ url_for('querytext') }}">
<div>
<label for="query">Describe here the street you want to get in 3DStreet:</label>
<textarea name="query" id="query" ></textarea>
</div>
<div>
<button>Send my query</button>
</div>
</form>
</body>
</html>
Loading