Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
许航嘉
geojson-vt-LSGlobe
Commits
7cfb6391
Commit
7cfb6391
authored
9 years ago
by
Vladimir Agafonkin
Browse files
Options
Download
Email Patches
Plain Diff
do not tile empty geojson, close #40
parent
76140fe4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
src/index.js
src/index.js
+2
-2
test/fixtures/empty.json
test/fixtures/empty.json
+4
-0
test/test-full.js
test/test-full.js
+5
-0
No files found.
src/index.js
View file @
7cfb6391
...
...
@@ -36,10 +36,10 @@ function GeoJSONVT(data, options) {
features
=
wrap
(
features
,
options
.
buffer
/
options
.
extent
,
intersectX
);
// start slicing from the top tile down
this
.
splitTile
(
features
,
0
,
0
,
0
);
if
(
features
.
length
)
this
.
splitTile
(
features
,
0
,
0
,
0
);
if
(
debug
)
{
console
.
log
(
'
features: %d, points: %d
'
,
this
.
tiles
[
0
].
numFeatures
,
this
.
tiles
[
0
].
numPoints
);
if
(
features
.
length
)
console
.
log
(
'
features: %d, points: %d
'
,
this
.
tiles
[
0
].
numFeatures
,
this
.
tiles
[
0
].
numPoints
);
console
.
timeEnd
(
'
generate tiles
'
);
console
.
log
(
'
tiles generated:
'
,
this
.
total
,
JSON
.
stringify
(
this
.
stats
));
}
...
...
This diff is collapsed.
Click to expand it.
test/fixtures/empty.json
0 → 100644
View file @
7cfb6391
{
"type"
:
"FeatureCollection"
,
"features"
:
[]
}
This diff is collapsed.
Click to expand it.
test/test-full.js
View file @
7cfb6391
...
...
@@ -24,6 +24,11 @@ function testTiles(inputFile, expectedFile, maxZoom, maxPoints) {
});
}
test
(
'
empty geojson
'
,
function
(
t
)
{
t
.
same
(
genTiles
(
getJSON
(
'
empty.json
'
)),
{});
t
.
end
();
});
function
getJSON
(
name
)
{
return
JSON
.
parse
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
/fixtures/
'
+
name
)));
}
This diff is collapsed.
Click to expand it.
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