Skip to content

Commit d7b72e9

Browse files
authored
Merge pull request #649 from OpenGeoscience/line-rendering
Refactor GL line rendering
2 parents f55e449 + dd7b0a6 commit d7b72e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1733
-491
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ cache:
3131
- "$HOME/cache"
3232

3333
before_install:
34+
# Start xvfb with a specific resolution and pixel depth
35+
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x24"
3436
- CACHE="${HOME}/cache" CMAKE_VERSION=3.5.0 CMAKE_SHORT_VERSION=3.5 source ./scripts/install_cmake.sh
3537
- npm prune
3638

3739
before_script:
3840
- export DISPLAY=:99.0
39-
- sh -e /etc/init.d/xvfb start
4041

4142
script:
4243
- npm run build

CMakeLists.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ add_custom_target(
9999
)
100100
add_test(NAME get_data_files COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target data_files)
101101

102+
add_custom_command(OUTPUT "${GEOJS_DEPLOY_DIR}/examples/bundle.js"
103+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
104+
COMMAND npm run build-examples
105+
COMMENT "Build examples"
106+
VERBATIM
107+
)
108+
add_custom_target(examples DEPENDS "${GEOJS_DEPLOY_DIR}/examples/bundle.js")
109+
add_test(NAME build_examples COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target examples)
110+
set_property(TEST "build_examples" APPEND PROPERTY DEPENDS "get_data_files")
111+
102112
if(FFHEADLESS_TESTS)
103113
find_program(NPM_EXECUTABLE npm)
104114
add_test(
@@ -111,6 +121,16 @@ if(FFHEADLESS_TESTS)
111121
set_property(TEST "total-coverage" APPEND PROPERTY DEPENDS "ffheadless")
112122
set_property(TEST "ffheadless" APPEND PROPERTY DEPENDS "get_data_files")
113123

124+
add_test(
125+
NAME "examplesheadless"
126+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
127+
COMMAND npm run examplesci
128+
)
129+
set_property(TEST "examplesheadless" APPEND PROPERTY ENVIRONMENT "CTEST_IMAGE_PATH=${CMAKE_CURRENT_BINARY_DIR}/images")
130+
set_property(TEST "examplesheadless" APPEND PROPERTY ENVIRONMENT "TEST_SAVE_IMAGE=${TEST_SAVE_IMAGE}")
131+
set_property(TEST "total-coverage" APPEND PROPERTY DEPENDS "examplesheadless")
132+
set_property(TEST "examplesheadless" APPEND PROPERTY DEPENDS "build_examples")
133+
114134
configure_file(
115135
"${CMAKE_CURRENT_SOURCE_DIR}/testing/test-runners/baseline_images.py"
116136
"${CMAKE_CURRENT_BINARY_DIR}/test/baseline_images.py"
@@ -124,8 +144,12 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/base-images.tgz"
124144
COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target data_files
125145
# Run the ffheadless test, asking to save all images
126146
COMMAND TEST_SAVE_IMAGE=all npm run ffci
147+
# Build examples to make sure that they are available.
148+
COMMAND npm run build-examples
149+
# Run the examplesheadless test, asking to save all images
150+
COMMAND TEST_SAVE_IMAGE=all npm run examplesci
127151
# Make a tarball of all of the images
128-
COMMAND tar -zcvf "${CMAKE_CURRENT_BINARY_DIR}/base-images.tgz" --exclude=*-test.png --exclude=*-diff.png --exclude=*-base.png -C "${CMAKE_CURRENT_BINARY_DIR}/images" .
152+
COMMAND tar -zcvf "${CMAKE_CURRENT_BINARY_DIR}/base-images.tgz" --exclude=*-test.png --exclude=*-diff.png --exclude=*-base.png --exclude=*-screen.png -C "${CMAKE_CURRENT_BINARY_DIR}/images" .
129153
COMMENT "Create baseline images, then tar them into a single file"
130154
VERBATIM
131155
)
@@ -208,9 +232,6 @@ if(SELENIUM_TESTS)
208232
set_property(TEST "selenium:glPointsSpeed" APPEND PROPERTY ENVIRONMENT "LOAD_SPEED_THRESHOLD=1000")
209233
set_property(TEST "selenium:glPointsSpeed" APPEND PROPERTY ENVIRONMENT "FRAMERATE_THRESHOLD=5")
210234

211-
set_property(TEST "selenium:glLinesSpeed" APPEND PROPERTY ENVIRONMENT "LOAD_SPEED_THRESHOLD=1000")
212-
set_property(TEST "selenium:glLinesSpeed" APPEND PROPERTY ENVIRONMENT "FRAMERATE_THRESHOLD=2")
213-
214235
add_custom_target(
215236
selenium_tests
216237
ALL

docs/developers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ test command or set this parameter in CMake.
109109
build correctly. Try running ``ccmake /path/to/geojs`` for a full
110110
list of configuration options.
111111

112+
Examples should be tested by creating an entry in the ``tests/example-cases/``
113+
directory. To run these tests in a normal browser, run
114+
``npm run start`` and browse to `<http://localhost:9876/debug.html?test=all>`_.
115+
Since the browser's direct screen output is used, the browser must be running
116+
on the same machine as the ``npm run start`` command.
117+
112118
Selenium testing
113119
----------------
114120

docs/provisioning.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ convenience in configuring CMake options) ::
2424
sudo apt-get install --yes \
2525
cmake \
2626
firefox \
27+
imagemagick \
2728
git \
2829
libjpeg8-dev \
2930
libpango1.0-dev \

examples/hurricanes/main.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
body {
2+
overflow: hidden;
3+
}
14
#app-hovered-info {
25
position: absolute;
36
bottom: 10px;

examples/lines/example.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"path": "lines",
3+
"title": "Line Feature",
4+
"exampleCss": ["main.css"],
5+
"exampleJs": ["main.js"],
6+
"about": {
7+
"text": "This example shows the variations that are available for line features."
8+
}
9+
}

examples/lines/index.jade

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
extends ../common/templates/index.jade
2+
3+
block append mainContent
4+
div#controls
5+
.form-group(title="Number of lines segments. Leave blank for a small default value.")
6+
label(for="lines") Number of Lines
7+
input#lines(type="number" min="1" step="100")
8+
span#lines-shown
9+
.form-group(title="Stroke Color (any css color). A comma-separated list will cycle through the listed colors. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to colors, with undefined values using the 'other' entry.")
10+
label(for="strokeColor") strokeColor
11+
input#strokeColor(placeholder="black")
12+
.form-group(title="Stroke Opacity (a number in the range [0, 1]). A comma-separated list will cycle through the listed opacities. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to opacities, with undefined values using the 'other' entry.")
13+
label(for="strokeOpacity") strokeOpacity
14+
input#strokeOpacity(placeholder="1")
15+
.form-group(title="Stroke Width (a positive number). A comma-separated list will cycle through the listed widths. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to widths, with undefined values using the 'other' entry.")
16+
label(for="strokeWidth") strokeWidth
17+
input#strokeWidth(placeholder="2")
18+
.form-group(title="Stroke Offset (a number in the range [-1, 1]). A comma-separated list will cycle through the listed offsets. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to offsets, with undefined values using the 'other' entry.")
19+
label(for="strokeOffset") strokeOffset
20+
input#strokeOffset(placeholder="0")
21+
.form-group(title="Line Cap (one of 'butt', 'round', or 'square'). A comma-separated list will cycle through the listed line caps. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to line caps, with undefined values using the 'other' entry.")
22+
label(for="lineCap") lineCap
23+
input#lineCap(placeholder="butt")
24+
.form-group(title="Line Join (one of 'miter', 'bevel', 'round', or 'miter-clip'). A comma-separated list will cycle through the listed line joins. line:(comma-separate list) will cycle through by line. A JSON dictionary will map road categories to line joins, with undefined values using the 'other' entry.")
25+
label(for="lineJoin") lineJoin
26+
input#lineJoin(placeholder="miter")
27+
.form-group(title="Miter Limit (a positive number). Any miter whose length relative to the stroke with longer than this value will either be beveled or clipped.")
28+
label(for="miterLimit") miterLimit
29+
input#miterLimit(placeholder="10")
30+
.form-group(title="Antialiasing (a non-negative number). Edges of lines will be antialiased by this many pixels. Values larger than 2 tend to make things blurry.")
31+
label(for="antialiasing") antialiasing
32+
input#antialiasing(placeholder="2")
33+
.form-group(title="Show road names and categories on hover.")
34+
label(for="hovertext") Info on Hover
35+
input#hovertext(type="checkbox", placeholder="false")
36+
.form-group(title="Show an OSM map underneath the lines.")
37+
label(for="showmap") Show Map
38+
input#showmap(type="checkbox", placeholder="true", checked="checked")
39+
.form-group
40+
.shortlabel Presets
41+
button.preset(strokeColor='{"residential":"blue","service":"green","other":"black"}', strokeWidth='{"residential":4,"service":1,"other":8}', lineCap='round', showmap='true', title='Properties based on road category') Categories
42+
button.preset(strokeColor='', strokeWidth='{"residential":1,"service":0.25,"other":3}', lineCap='round', lineJoin='', miterLimit='', showmap='false', title='Thin lines based on road category') Thin
43+
button.preset(strokeColor='line:red,orange,yellow,green,blue,indigo,violet', strokeWidth='line:1,2,4,8,16', lineCap='line:butt,round,square', lineJoin='line:miter,bevel,round,miter-clip', miterLimit=4, title='Properties varied by line') Lines
44+
button.preset(strokeColor='red,orange,yellow,green,blue,indigo,violet', strokeWidth='1,2,4,8,16', lineCap='butt,round,square', lineJoin='miter,bevel,round,miter-clip', miterLimit=4, title='Properties varied by line segment') Segments
45+

examples/lines/main.css

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#controls {
2+
overflow-x: hidden;
3+
overflow-y: auto;
4+
position: absolute;
5+
left: 10px;
6+
top: 80px;
7+
z-index: 2;
8+
border-radius: 5px;
9+
border: 1px solid grey;
10+
box-shadow: 1px 1px 3px black;
11+
opacity: 0.5;
12+
transition: opacity 250ms ease;
13+
background: #CCC;
14+
color: black;
15+
padding: 4px;
16+
font-size: 14px;
17+
max-height: calc(100% - 100px);
18+
min-width: 310px;
19+
}
20+
#controls:hover {
21+
opacity: 1;
22+
}
23+
#controls .form-group {
24+
margin-bottom: 0;
25+
}
26+
#controls label {
27+
min-width: 120px;
28+
}
29+
#controls #lines {
30+
width: 100px;
31+
}
32+
#controls #lines-loaded,#controls #lines-shown {
33+
display: inline-block;
34+
font-size: 11px;
35+
padding-left: 5px;
36+
}
37+
#controls table input {
38+
width: 55px;
39+
}
40+
#controls table th {
41+
text-align: center;
42+
}
43+
.shortlabel {
44+
margin-bottom: 5px;
45+
font-weight: bold;
46+
display: inline-block;
47+
}
48+
#tooltip {
49+
margin-left: 0px;
50+
margin-top: -20px;
51+
height: 20px;
52+
line-height: 16px;
53+
padding: 2px 5px;
54+
background: rgba(255, 255, 255, 0.75);
55+
border-radius: 10px;
56+
border-bottom-left-radius: 0;
57+
border: 1px solid rgba(0, 0, 0, 0.75);
58+
font-size: 12px;
59+
color: black;
60+
}

0 commit comments

Comments
 (0)