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
41ab664b
Commit
41ab664b
authored
10 years ago
by
Vladimir Agafonkin
Browse files
Options
Download
Email Patches
Plain Diff
add a debug switch
parent
ff900316
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
src/index.js
src/index.js
+18
-11
src/tile.js
src/tile.js
+2
-0
No files found.
src/index.js
View file @
41ab664b
...
...
@@ -11,7 +11,9 @@ var clip = require('./clip'),
padding
=
0.05
,
// padding on each side of tile in percentage
minPx
=
Math
.
round
(
-
padding
*
extent
),
maxPx
=
Math
.
round
((
1
+
padding
)
*
extent
);
maxPx
=
Math
.
round
((
1
+
padding
)
*
extent
),
debug
=
true
;
function
geojsonvt
(
data
,
maxZoom
)
{
...
...
@@ -23,7 +25,7 @@ function GeoJSONVT(data, maxZoom) {
this
.
maxZoom
=
maxZoom
;
this
.
maxPoints
=
100
;
console
.
time
(
'
preprocess features
'
);
if
(
debug
)
console
.
time
(
'
preprocess features
'
);
var
features
=
[],
z2
=
Math
.
pow
(
2
,
maxZoom
);
...
...
@@ -31,14 +33,14 @@ function GeoJSONVT(data, maxZoom) {
var
feature
=
convert
(
data
.
features
[
i
],
tolerance
/
z2
);
if
(
feature
)
features
.
push
(
feature
);
}
console
.
timeEnd
(
'
preprocess features
'
);
if
(
debug
)
console
.
timeEnd
(
'
preprocess features
'
);
this
.
tiles
=
{};
this
.
stats
=
{};
console
.
time
(
'
generate tiles
'
);
if
(
debug
)
console
.
time
(
'
generate tiles
'
);
this
.
splitTile
(
features
,
0
,
0
,
0
);
console
.
timeEnd
(
'
generate tiles
'
);
if
(
debug
)
console
.
timeEnd
(
'
generate tiles
'
);
}
GeoJSONVT
.
prototype
.
splitTile
=
function
(
features
,
z
,
x
,
y
)
{
...
...
@@ -56,11 +58,16 @@ GeoJSONVT.prototype.splitTile = function (features, z, x, y) {
tile
=
this
.
tiles
[
id
];
if
(
!
tile
)
{
// console.time('creation');
if
(
debug
)
console
.
time
(
'
creation
'
);
tile
=
this
.
tiles
[
id
]
=
createTile
(
features
,
z2
,
x
,
y
,
tolerance
/
z2
,
extent
);
// console.log('tile z' + z + '-' + x + '-' + y + ' points: ' + tile.numPoints + ', simplified: ' + tile.numSimplified);
// console.timeEnd('creation');
this
.
stats
[
z
]
=
(
this
.
stats
[
z
]
||
0
)
+
1
;
if
(
debug
)
{
console
.
log
(
'
tile z
'
+
z
+
'
-
'
+
x
+
'
-
'
+
y
+
'
(features:
'
+
tile
.
numFeatures
+
'
, points:
'
+
tile
.
numPoints
+
'
, simplified:
'
+
tile
.
numSimplified
+
'
)
'
);
console
.
timeEnd
(
'
creation
'
);
this
.
stats
[
z
]
=
(
this
.
stats
[
z
]
||
0
)
+
1
;
}
}
if
(
z
===
this
.
maxZoom
||
tile
.
numPoints
<=
this
.
maxPoints
||
isClippedSquare
(
tile
.
features
))
{
...
...
@@ -71,7 +78,7 @@ GeoJSONVT.prototype.splitTile = function (features, z, x, y) {
// clean up the original features since we'll have them in children tiles
tile
.
source
=
null
;
//
console.time('clipping');
if
(
debug
)
console
.
time
(
'
clipping
'
);
var
k1
=
0.5
*
padding
,
k2
=
0.5
-
k1
,
...
...
@@ -96,7 +103,7 @@ GeoJSONVT.prototype.splitTile = function (features, z, x, y) {
br
=
clip
(
right
,
z2
,
y
+
k2
,
y
+
k4
,
1
,
intersectY
);
}
//
console.timeEnd('clipping');
if
(
debug
)
console
.
timeEnd
(
'
clipping
'
);
if
(
tl
)
stack
.
push
(
tl
,
z
+
1
,
x
*
2
,
y
*
2
);
if
(
bl
)
stack
.
push
(
bl
,
z
+
1
,
x
*
2
,
y
*
2
+
1
);
...
...
This diff is collapsed.
Click to expand it.
src/tile.js
View file @
41ab664b
...
...
@@ -7,9 +7,11 @@ function createTile(features, z2, tx, ty, tolerance, extent) {
features
:
[],
numPoints
:
0
,
numSimplified
:
0
,
numFeatures
:
0
,
source
:
null
};
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
tile
.
numFeatures
++
;
addFeature
(
tile
,
features
[
i
],
z2
,
tx
,
ty
,
tolerance
,
extent
);
}
return
tile
;
...
...
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