use of rtree.IllegalValueException in project OsmAnd-tools by osmandapp.
the class IndexVectorMapCreator method calcBounds.
public Rect calcBounds(rtree.Node n) {
Rect r = null;
Element[] e = n.getAllElements();
for (int i = 0; i < n.getTotalElements(); i++) {
Rect re = e[i].getRect();
if (r == null) {
try {
r = new Rect(re.getMinX(), re.getMinY(), re.getMaxX(), re.getMaxY());
} catch (IllegalValueException ex) {
}
} else {
r.expandToInclude(re);
}
}
return r;
}
use of rtree.IllegalValueException in project OsmAnd-tools by osmandapp.
the class IndexVectorMapCreator method insertBinaryMapRenderObjectIndex.
private void insertBinaryMapRenderObjectIndex(RTree mapTree, Collection<Node> nodes, List<List<Node>> innerWays, Map<MapRulType, String> names, long id, boolean area, TIntArrayList types, TIntArrayList addTypes, boolean commit) throws SQLException {
boolean init = false;
int minX = Integer.MAX_VALUE;
int maxX = 0;
int minY = Integer.MAX_VALUE;
int maxY = 0;
ByteArrayOutputStream bcoordinates = new ByteArrayOutputStream();
ByteArrayOutputStream binnercoord = new ByteArrayOutputStream();
ByteArrayOutputStream btypes = new ByteArrayOutputStream();
ByteArrayOutputStream badditionalTypes = new ByteArrayOutputStream();
try {
for (int j = 0; j < types.size(); j++) {
Algorithms.writeSmallInt(btypes, types.get(j));
}
for (int j = 0; j < addTypes.size(); j++) {
Algorithms.writeSmallInt(badditionalTypes, addTypes.get(j));
}
for (Node n : nodes) {
if (n != null) {
int y = MapUtils.get31TileNumberY(n.getLatitude());
int x = MapUtils.get31TileNumberX(n.getLongitude());
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
init = true;
Algorithms.writeInt(bcoordinates, x);
Algorithms.writeInt(bcoordinates, y);
}
}
if (innerWays != null) {
for (List<Node> ws : innerWays) {
boolean exist = false;
if (ws != null) {
for (Node n : ws) {
if (n != null) {
exist = true;
int y = MapUtils.get31TileNumberY(n.getLatitude());
int x = MapUtils.get31TileNumberX(n.getLongitude());
Algorithms.writeInt(binnercoord, x);
Algorithms.writeInt(binnercoord, y);
}
}
}
if (exist) {
Algorithms.writeInt(binnercoord, 0);
Algorithms.writeInt(binnercoord, 0);
}
}
}
} catch (IOException es) {
throw new IllegalStateException(es);
}
if (init) {
// conn.prepareStatement("insert into binary_map_objects(id, area, coordinates, innerPolygons, types, additionalTypes, name) values(?, ?, ?, ?, ?, ?, ?)");
mapBinaryStat.setLong(1, id);
mapBinaryStat.setBoolean(2, area);
mapBinaryStat.setBytes(3, bcoordinates.toByteArray());
mapBinaryStat.setBytes(4, binnercoord.toByteArray());
mapBinaryStat.setBytes(5, btypes.toByteArray());
mapBinaryStat.setBytes(6, badditionalTypes.toByteArray());
mapBinaryStat.setString(7, encodeNames(names));
addBatch(mapBinaryStat, commit);
try {
mapTree.insert(new LeafElement(new Rect(minX, minY, maxX, maxY), id));
} catch (RTreeInsertException e1) {
throw new IllegalArgumentException(e1);
} catch (IllegalValueException e1) {
throw new IllegalArgumentException(e1);
}
}
}
use of rtree.IllegalValueException in project OsmAnd-tools by osmandapp.
the class IndexUploader method calcBounds.
public static Rect calcBounds(rtree.Node n) {
Rect r = null;
rtree.Element[] e = n.getAllElements();
for (int i = 0; i < n.getTotalElements(); i++) {
Rect re = e[i].getRect();
if (r == null) {
try {
r = new Rect(re.getMinX(), re.getMinY(), re.getMaxX(), re.getMaxY());
} catch (IllegalValueException ex) {
}
} else {
r.expandToInclude(re);
}
}
return r;
}
Aggregations