Vector layers: clip to max GL.Short resolution (#529)

This commit is contained in:
Gustl22 2018-04-17 09:54:09 +02:00 committed by Emux
parent b240be8ba7
commit ccfbb359a4
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
3 changed files with 28 additions and 5 deletions

View File

@ -5,6 +5,7 @@
* Copyright 2016 Bezzu
* Copyright 2016 Pedinel
* Copyright 2017 Andrey Novikov
* Copyright 2018 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -35,6 +36,7 @@ import org.oscim.event.MotionEvent;
import org.oscim.map.Map;
import org.oscim.renderer.BucketRenderer;
import org.oscim.renderer.GLViewport;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.bucket.LineBucket;
import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.theme.styles.LineStyle;
@ -259,12 +261,12 @@ public class PathLayer extends Layer implements GestureListener {
final class Worker extends SimpleWorker<Task> {
// limit coords
private final int max = 2048;
// limit coords to maximum resolution of GL.Short
private final int MAX_CLIP = (int) (Short.MAX_VALUE / MapRenderer.COORD_SCALE);
public Worker(Map map) {
super(map, 0, new Task(), new Task());
mClipper = new LineClipper(-max, -max, max, max);
mClipper = new LineClipper(-MAX_CLIP, -MAX_CLIP, MAX_CLIP, MAX_CLIP);
mPPoints = new float[0];
}

View File

@ -1,3 +1,20 @@
/*
* Copyright 2014 Hannes Janetzek
* Copyright 2018 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.layers.vector;
import org.oscim.core.Box;
@ -10,6 +27,7 @@ import org.oscim.map.Map.UpdateListener;
import org.oscim.map.Viewport;
import org.oscim.renderer.BucketRenderer;
import org.oscim.renderer.GLViewport;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.utils.async.SimpleWorker;
import org.oscim.utils.geom.TileClipper;
@ -21,8 +39,11 @@ public abstract class AbstractVectorLayer<T> extends Layer implements UpdateList
protected final static double UNSCALE_COORD = 4;
// limit coords to maximum resolution of GL.Short
private static final int MAX_CLIP = (int) (Short.MAX_VALUE / MapRenderer.COORD_SCALE);
protected final GeometryBuffer mGeom = new GeometryBuffer(128, 4);
protected final TileClipper mClipper = new TileClipper(-1024, -1024, 1024, 1024);
protected final TileClipper mClipper = new TileClipper(-MAX_CLIP, -MAX_CLIP, MAX_CLIP, MAX_CLIP);
protected final Worker mWorker;
protected long mUpdateDelay = 50;

View File

@ -35,7 +35,7 @@ import static org.oscim.renderer.MapRenderer.COORD_SCALE;
/**
* Note:
* Coordinates must be in range [-4096..4096] and the maximum
* Coordinates must be in range +/- (Short.MAX_VALUE / COORD_SCALE) and the maximum
* resolution for coordinates is 0.25 as points will be converted
* to fixed point values.
*/