use of gnu.trove.iterator.TLongIterator in project OsmAnd-tools by osmandapp.
the class CheckRoadConnectivity method mergeable.
private boolean mergeable(Cluster a, Cluster b) {
boolean order = a.points.size() < b.points.size();
Cluster as = order ? a : b;
Cluster bs = order ? b : a;
TLongIterator iterator = as.points.iterator();
while (iterator.hasNext()) {
if (bs.points.contains(iterator.next())) {
return true;
}
}
return false;
}
use of gnu.trove.iterator.TLongIterator in project Osmand by osmandapp.
the class BinaryInspector method printWay.
private long printWay(TLongArrayList ids, StringBuilder b, StringBuilder tags) {
int id = OSM_ID++;
b.append("<way id = '" + id + "' version='1'>\n");
if (tags != null) {
b.append(tags);
}
TLongIterator it = ids.iterator();
while (it.hasNext()) {
long ref = it.next();
b.append("\t<nd ref = '" + ref + "'/>\n");
}
b.append("</way>\n");
return id;
}
use of gnu.trove.iterator.TLongIterator in project Osmand by osmandapp.
the class RoutingContext method loadTileData.
public void loadTileData(int x31, int y31, int zoomAround, final List<RouteDataObject> toFillIn) {
int t = config.ZOOM_TO_LOAD_TILES - zoomAround;
int coordinatesShift = (1 << (31 - config.ZOOM_TO_LOAD_TILES));
if (t <= 0) {
t = 1;
coordinatesShift = (1 << (31 - zoomAround));
} else {
t = 1 << t;
}
TLongHashSet ts = new TLongHashSet();
long now = System.nanoTime();
for (int i = -t; i <= t; i++) {
for (int j = -t; j <= t; j++) {
ts.add(getRoutingTile(x31 + i * coordinatesShift, y31 + j * coordinatesShift, 0, OPTION_IN_MEMORY_LOAD));
}
}
TLongIterator it = ts.iterator();
TLongObjectHashMap<RouteDataObject> excludeDuplications = new TLongObjectHashMap<RouteDataObject>();
while (it.hasNext()) {
getAllObjects(it.next(), toFillIn, excludeDuplications);
}
timeToFindInitialSegments += (System.nanoTime() - now);
}
use of gnu.trove.iterator.TLongIterator in project Terasology by MovingBlocks.
the class EntityRefTypeHandler method addEntitiesFromLongArray.
private void addEntitiesFromLongArray(List<EntityRef> result, PersistedDataArray array) {
TLongIterator iterator = array.getAsLongArray().iterator();
while (iterator.hasNext()) {
long item = iterator.next();
result.add(entityManager.getEntity(item));
}
}
use of gnu.trove.iterator.TLongIterator in project Osmand by osmandapp.
the class BinaryInspector method printOsmMapDetails.
private void printOsmMapDetails(BinaryMapDataObject obj, StringBuilder b) {
boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
boolean point = obj.getPointsLength() == 1;
StringBuilder tags = new StringBuilder();
int[] types = obj.getTypes();
for (int j = 0; j < types.length; j++) {
TagValuePair pair = obj.getMapIndex().decodeType(types[j]);
if (pair == null) {
throw new NullPointerException("Type " + types[j] + "was not found");
}
tags.append("\t<tag k='").append(pair.tag).append("' v='").append(quoteName(pair.value)).append("' />\n");
}
if (obj.getAdditionalTypes() != null && obj.getAdditionalTypes().length > 0) {
for (int j = 0; j < obj.getAdditionalTypes().length; j++) {
int addtype = obj.getAdditionalTypes()[j];
TagValuePair pair = obj.getMapIndex().decodeType(addtype);
if (pair == null) {
throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
}
tags.append("\t<tag k='").append(pair.tag).append("' v='").append(quoteName(pair.value)).append("' />\n");
}
}
TIntObjectHashMap<String> names = obj.getObjectNames();
if (names != null && !names.isEmpty()) {
int[] keys = names.keys();
for (int j = 0; j < keys.length; j++) {
TagValuePair pair = obj.getMapIndex().decodeType(keys[j]);
if (pair == null) {
throw new NullPointerException("Type " + keys[j] + "was not found");
}
String name = names.get(keys[j]);
name = quoteName(name);
tags.append("\t<tag k='").append(pair.tag).append("' v='").append(name).append("' />\n");
}
}
tags.append("\t<tag k=\'").append("original_id").append("' v='").append(obj.getId() >> (SHIFT_ID + 1)).append("'/>\n");
tags.append("\t<tag k=\'").append("osmand_id").append("' v='").append(obj.getId()).append("'/>\n");
if (point) {
float lon = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
b.append("<node id = '" + OSM_ID++ + "' version='1' lat='" + lat + "' lon='" + lon + "' >\n");
b.append(tags);
b.append("</node>\n");
} else {
TLongArrayList innerIds = new TLongArrayList();
TLongArrayList ids = new TLongArrayList();
for (int i = 0; i < obj.getPointsLength(); i++) {
float lon = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(i));
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
int id = OSM_ID++;
b.append("\t<node id = '" + id + "' version='1' lat='" + lat + "' lon='" + lon + "' />\n");
ids.add(id);
}
long outerId = printWay(ids, b, multipolygon ? null : tags);
if (multipolygon) {
int[][] polygonInnerCoordinates = obj.getPolygonInnerCoordinates();
for (int j = 0; j < polygonInnerCoordinates.length; j++) {
ids.clear();
for (int i = 0; i < polygonInnerCoordinates[j].length; i += 2) {
float lon = (float) MapUtils.get31LongitudeX(polygonInnerCoordinates[j][i]);
float lat = (float) MapUtils.get31LatitudeY(polygonInnerCoordinates[j][i + 1]);
int id = OSM_ID++;
b.append("<node id = '" + id + "' version='1' lat='" + lat + "' lon='" + lon + "' />\n");
ids.add(id);
}
innerIds.add(printWay(ids, b, null));
}
int id = OSM_ID++;
b.append("<relation id = '" + id + "' version='1'>\n");
b.append(tags);
b.append("\t<member type='way' role='outer' ref= '" + outerId + "'/>\n");
TLongIterator it = innerIds.iterator();
while (it.hasNext()) {
long ref = it.next();
b.append("<member type='way' role='inner' ref= '" + ref + "'/>\n");
}
b.append("</relation>\n");
}
}
}
Aggregations