From ccfbb359a44ca5d82bb59b8d8ac48cfcf6ff11b1 Mon Sep 17 00:00:00 2001 From: Gustl22 <user.rebo@gmx.de> Date: Tue, 17 Apr 2018 09:54:09 +0200 Subject: [PATCH] Vector layers: clip to max GL.Short resolution (#529) --- vtm/src/org/oscim/layers/PathLayer.java | 8 ++++--- .../layers/vector/AbstractVectorLayer.java | 23 ++++++++++++++++++- .../org/oscim/renderer/bucket/LineBucket.java | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/vtm/src/org/oscim/layers/PathLayer.java b/vtm/src/org/oscim/layers/PathLayer.java index bea9a34e..f07c0abc 100644 --- a/vtm/src/org/oscim/layers/PathLayer.java +++ b/vtm/src/org/oscim/layers/PathLayer.java @@ -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]; } diff --git a/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java b/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java index 086184e4..d4fa298d 100644 --- a/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java +++ b/vtm/src/org/oscim/layers/vector/AbstractVectorLayer.java @@ -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; diff --git a/vtm/src/org/oscim/renderer/bucket/LineBucket.java b/vtm/src/org/oscim/renderer/bucket/LineBucket.java index 6b5f3495..6b46011c 100644 --- a/vtm/src/org/oscim/renderer/bucket/LineBucket.java +++ b/vtm/src/org/oscim/renderer/bucket/LineBucket.java @@ -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. */