API: GeometryBuffer add getNumPoints(), getPoint():PointF
- ignore start of new geometry when the current is empty
This commit is contained in:
parent
1a4e3b4c7c
commit
949ebb5d8e
@ -21,6 +21,8 @@ public class GeometryBuffer {
|
||||
private final static int GROW_INDICES = 64;
|
||||
private final static int GROW_POINTS = 512;
|
||||
|
||||
private PointF mTmpPoint = new PointF();
|
||||
|
||||
/**
|
||||
* The Enum GeometryType.
|
||||
*/
|
||||
@ -72,6 +74,16 @@ public class GeometryBuffer {
|
||||
this.pointPos = 0;
|
||||
}
|
||||
|
||||
public PointF getPoint(int i) {
|
||||
mTmpPoint.x = points[(i << 1)];
|
||||
mTmpPoint.y = points[(i << 1) + 1];
|
||||
return mTmpPoint;
|
||||
}
|
||||
|
||||
public int getNumPoints() {
|
||||
return index[0] >> 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new geometry buffer.
|
||||
*
|
||||
@ -146,6 +158,10 @@ public class GeometryBuffer {
|
||||
public void startLine() {
|
||||
setOrCheckMode(GeometryType.LINE);
|
||||
|
||||
// ignore
|
||||
if (index[indexPos] == 0)
|
||||
return;
|
||||
|
||||
// start next
|
||||
if ((index[0] >= 0) && (++indexPos >= index.length))
|
||||
ensureIndexSize(indexPos, true);
|
||||
@ -165,6 +181,10 @@ public class GeometryBuffer {
|
||||
boolean start = (type == GeometryType.NONE);
|
||||
setOrCheckMode(GeometryType.POLY);
|
||||
|
||||
// ignore
|
||||
if (index[indexPos] == 0)
|
||||
return;
|
||||
|
||||
if ((indexPos + 3) > index.length)
|
||||
ensureIndexSize(indexPos + 2, true);
|
||||
|
||||
|
||||
41
vtm/src/org/oscim/core/PointF.java
Normal file
41
vtm/src/org/oscim/core/PointF.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* 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.core;
|
||||
|
||||
public class PointF {
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
public PointF() {
|
||||
}
|
||||
|
||||
public PointF(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + " " + y;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user