Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
df-aggregator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
df-aggregator
Commits
c0d25d6e
Commit
c0d25d6e
authored
Nov 04, 2020
by
Corey Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cesium Web Display Works
parent
9787e0bc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
65 deletions
+103
-65
.gitignore
.gitignore
+1
-0
df-aggregator.py
df-aggregator.py
+87
-19
cesium.tpl
views/cesium.tpl
+15
-20
webgui.py
webgui.py
+0
-26
No files found.
.gitignore
View file @
c0d25d6e
...
...
@@ -6,3 +6,4 @@ CesiumJS/
test*
*.db
*.txt
*.czml
df-aggregator.py
View file @
c0d25d6e
...
...
@@ -6,13 +6,16 @@ import math
import
time
import
sqlite3
import
threading
import
webgui
#
import webgui
from
optparse
import
OptionParser
from
os
import
system
,
name
from
lxml
import
etree
from
sklearn.cluster
import
DBSCAN
from
sklearn.preprocessing
import
StandardScaler
from
geojson
import
Point
,
MultiPoint
,
Feature
,
FeatureCollection
from
czml3
import
Packet
,
Document
,
Preamble
from
bottle
import
route
,
run
,
request
,
get
,
post
,
redirect
,
template
,
static_file
d
=
40000
#meters
...
...
@@ -156,7 +159,7 @@ def process_data(database_name, outfile, eps, min_samp):
# Number of clusters in labels, ignoring noise if present.
n_clusters_
=
len
(
set
(
labels
))
-
(
1
if
-
1
in
labels
else
0
)
n_noise_
=
list
(
labels
)
.
count
(
-
1
)
clear
()
#
clear()
print
(
'Number of clusters:
%
d'
%
n_clusters_
)
print
(
'Outliers Removed:
%
d'
%
n_noise_
)
# print(intersect_array)
...
...
@@ -166,11 +169,13 @@ def process_data(database_name, outfile, eps, min_samp):
for
y
in
range
(
len
(
intersect_array
)):
if
intersect_array
[
y
][
2
]
==
x
:
cluster
=
np
.
concatenate
((
cluster
,
[
intersect_array
[
y
][
0
:
2
]]),
axis
=
0
)
likely_location
.
append
(
Reverse
(
np
.
mean
(
cluster
,
axis
=
0
)
.
tolist
()
))
best_point
=
Feature
(
properties
=
best_pt_style
,
geometry
=
MultiPoint
(
tuple
(
likely_location
)))
likely_location
.
append
(
np
.
mean
(
cluster
,
axis
=
0
)
.
tolist
(
))
#
best_point = Feature(properties = best_pt_style, geometry = MultiPoint(tuple(likely_location)))
for
x
in
likely_location
:
print
(
Reverse
(
x
))
print
(
x
)
else
:
best_point
=
None
for
x
in
intersect_array
:
try
:
...
...
@@ -179,17 +184,62 @@ def process_data(database_name, outfile, eps, min_samp):
except
IndexError
:
intersect_list
.
append
(
Reverse
(
x
.
tolist
()))
#print(intersect_list)
all_the_points
=
Feature
(
properties
=
all_pt_style
,
geometry
=
MultiPoint
(
tuple
(
intersect_list
)))
#all_the_points = Feature(properties = all_pt_style, geometry = MultiPoint(tuple(intersect_list)))
return
likely_location
,
intersect_list
with
open
(
outfile
,
"w"
)
as
file1
:
if
eps
>
0
:
else
:
print
(
"No Intersections."
)
return
None
def
write_geojson
(
best_point
,
all_the_points
):
if
all_the_points
!=
None
:
all_the_points
=
Feature
(
properties
=
all_pt_style
,
geometry
=
MultiPoint
(
tuple
(
all_the_points
)))
with
open
(
geofile
,
"w"
)
as
file1
:
if
best_point
!=
None
:
best_point
=
Feature
(
properties
=
best_pt_style
,
geometry
=
MultiPoint
(
tuple
(
best_point
)))
file1
.
write
(
str
(
FeatureCollection
([
best_point
,
all_the_points
])))
else
:
file1
.
write
(
str
(
FeatureCollection
([
all_the_points
])))
print
(
f
"Wrote file {geofile}"
)
else
:
print
(
"No Intersections."
)
def
write_czml
(
best_point
,
all_the_points
):
print
(
best_point
)
point_properties
=
{
"pixelSize"
:
5.0
,
"heightReference"
:
"RELATIVE_TO_GROUND"
,
"color"
:
{
"rgba"
:
[
255
,
0
,
0
,
255
],
}
}
best_point_properties
=
{
"pixelSize"
:
20.0
,
"heightReference"
:
"RELATIVE_TO_GROUND"
,
"color"
:
{
"rgba"
:
[
0
,
255
,
0
,
255
],
}
}
top
=
Preamble
(
name
=
"Geolocation Data"
)
all_point_packets
=
[]
best_point_packets
=
[]
if
all_the_points
!=
None
:
for
x
in
all_the_points
:
all_point_packets
.
append
(
Packet
(
id
=
str
(
x
[
1
])
+
", "
+
str
(
x
[
0
]),
point
=
point_properties
,
position
=
{
"cartographicDegrees"
:
[
x
[
0
],
x
[
1
],
5
]}))
if
best_point
!=
None
:
for
x
in
best_point
:
best_point_packets
.
append
(
Packet
(
id
=
str
(
x
[
0
])
+
", "
+
str
(
x
[
1
]),
point
=
best_point_properties
,
position
=
{
"cartographicDegrees"
:
[
x
[
1
],
x
[
0
],
15
]}))
with
open
(
"static/output.czml"
,
"w"
)
as
file1
:
if
best_point
!=
None
:
file1
.
write
(
str
(
Document
([
top
]
+
best_point_packets
+
all_point_packets
)))
else
:
file1
.
write
(
str
(
Document
([
top
]
+
all_point_packets
)))
def
Reverse
(
lst
):
lst
.
reverse
()
...
...
@@ -203,11 +253,29 @@ def clear():
else
:
_
=
system
(
'clear'
)
with
open
(
'accesstoken.txt'
,
"r"
)
as
tokenfile
:
access_token
=
tokenfile
.
read
()
.
replace
(
'
\n
'
,
''
)
@route
(
'/static/<filepath:path>'
,
name
=
'static'
)
def
server_static
(
filepath
):
return
static_file
(
filepath
,
root
=
'./static'
)
@get
(
'/'
)
@get
(
'/index'
)
@get
(
'/cesium'
)
def
cesium
():
write_czml
(
*
process_data
(
database_name
,
geofile
,
eps
,
min_samp
))
return
template
(
'cesium.tpl'
,
{
'access_token'
:
access_token
})
def
start_server
(
ipaddr
=
"127.0.0.1"
):
run
(
host
=
ipaddr
,
port
=
8080
,
quiet
=
True
,
debug
=
False
,
server
=
'paste'
)
if
__name__
==
'__main__'
:
ipaddr
=
"127.0.0.1"
# web = threading.Thread(target=webgui.
start_server,)
#
web.daemon = True
#
web.start()
#
ipaddr = "127.0.0.1"
web
=
threading
.
Thread
(
target
=
start_server
,)
web
.
daemon
=
True
web
.
start
()
usage
=
"usage:
%
prog [options]"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"-g"
,
"--geofile"
,
dest
=
"geofile"
,
help
=
"GeoJSON Output File"
,
metavar
=
"FILE"
)
...
...
@@ -242,7 +310,7 @@ if __name__ == '__main__':
min_samp
=
options
.
minsamp
try
:
clear
()
#
clear()
dots
=
0
conn
=
sqlite3
.
connect
(
database_name
)
c
=
conn
.
cursor
()
...
...
@@ -313,13 +381,13 @@ if __name__ == '__main__':
dots
=
1
else
:
dots
+=
1
clear
()
#
clear()
except
KeyboardInterrupt
:
clear
()
#
clear()
print
(
"Processing, please wait."
)
conn
.
commit
()
conn
.
close
()
process_data
(
database_name
,
geofile
,
eps
,
min_samp
)
#
web.join()
write_geojson
(
*
process_data
(
database_name
,
geofile
,
eps
,
min_samp
)
)
web
.
join
()
quit
()
views/cesium.tpl
View file @
c0d25d6e
...
...
@@ -7,34 +7,29 @@
<link
href=
"https://cesium.com/downloads/cesiumjs/releases/1.75/Build/Cesium/Widgets/widgets.css"
rel=
"stylesheet"
>
</head>
<body>
<div
id=
"cesiumContainer"
></div>
<div
id=
"cesiumContainer"
style=
"height: 800px"
></div>
<script>
// Your access token can be found at: https://cesium.com/ion/tokens.
Cesium
.
Ion
.
defaultAccessToken
=
'{
{
access_token
}
}'
;
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
// const viewer = new Cesium.Viewer('cesiumContainer', {
// terrainProvider: Cesium.createWorldTerrain()
// });
var
viewer
=
new
Cesium
.
Viewer
(
'cesiumContainer'
,
{
terrainProvider
:
Cesium
.
createWorldTerrain
()
});
viewer
.
dataSources
.
add
(
Cesium
.
GeoJsonDataSource
.
load
(
'/static/dc_med.geojson'
,
{
clampToGround
:
true
,
markerColor
:
Cesium
.
Color
.
GREEN
,
markerSymbol
:
''
}));
// Add Cesium OSM Buildings, a global 3D buildings layer.
var
dataSourcePromise
=
Cesium
.
CzmlDataSource
.
load
(
'/static/output.czml'
);
viewer
.
dataSources
.
add
(
dataSourcePromise
);
viewer
.
zoomTo
(
dataSourcePromise
);
const
buildingTileset
=
viewer
.
scene
.
primitives
.
add
(
Cesium
.
createOsmBuildings
());
//
Fly the camera to San Francisco at the given longitude, latitude, and height.
//
viewer.camera.flyTo({
//
destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400)
,
//
orientation : {
//
heading : Cesium.Math.toRadians(0.0),
// pitch : Cesium.Math.toRadians(-15.0),
//
}
// });
//
viewer.dataSources.add(Cesium.GeoJsonDataSource.load('/static/dc_med.geojson', {
//
clampToGround: true,
//
//markerColor: Cesium.Color.GREEN
,
//
markerSymbol: ''
//
}));
//
Add Cesium OSM Buildings, a global 3D buildings layer.
</script>
</div>
<h2>
Marble Cake also the Game
</h2>
</body>
</html>
webgui.py
deleted
100644 → 0
View file @
9787e0bc
from
bottle
import
route
,
run
,
request
,
get
,
post
,
redirect
,
template
,
static_file
ipaddr
=
"127.0.0.1"
with
open
(
'accesstoken.txt'
,
"r"
)
as
tokenfile
:
access_token
=
tokenfile
.
read
()
.
replace
(
'
\n
'
,
''
)
@route
(
'/static/<filepath:path>'
,
name
=
'static'
)
def
server_static
(
filepath
):
return
static_file
(
filepath
,
root
=
'./static'
)
@get
(
'/'
)
@get
(
'/index'
)
def
hello
():
return
template
(
'index.tpl'
)
@get
(
'/cesium'
)
def
cesium
():
return
template
(
'cesium.tpl'
,
{
'access_token'
:
access_token
})
def
start_server
():
run
(
host
=
ipaddr
,
port
=
8080
,
quiet
=
True
,
debug
=
False
,
server
=
'paste'
)
if
__name__
==
'__main__'
:
start_server
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment