id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,300 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/dummy/ManyDummyContent.java | ManyDummyContent.downloadUrl | private InputStreamReader downloadUrl(String urlString) throws IOException {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
return new InputStreamReader(conn.getInputStream(), "UTF-8");
} | java | private InputStreamReader downloadUrl(String urlString) throws IOException {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
return new InputStreamReader(conn.getInputStream(), "UTF-8");
} | [
"private",
"InputStreamReader",
"downloadUrl",
"(",
"String",
"urlString",
")",
"throws",
"IOException",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"urlString",
")",
";",
"HttpURLConnection",
"conn",
"=",
"(",
"HttpURLConnection",
")",
"url",
".",
"openConnection",
"(",
")",
";",
"conn",
".",
"setReadTimeout",
"(",
"10000",
"/* milliseconds */",
")",
";",
"conn",
".",
"setConnectTimeout",
"(",
"15000",
"/* milliseconds */",
")",
";",
"conn",
".",
"setRequestMethod",
"(",
"\"GET\"",
")",
";",
"conn",
".",
"setDoInput",
"(",
"true",
")",
";",
"// Starts the query",
"conn",
".",
"connect",
"(",
")",
";",
"return",
"new",
"InputStreamReader",
"(",
"conn",
".",
"getInputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
";",
"}"
] | an input stream. | [
"an",
"input",
"stream",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/dummy/ManyDummyContent.java#L145-L157 |
28,301 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/cache/InMemoryTileCache.java | InMemoryTileCache.setCapacity | public synchronized void setCapacity(int capacity) {
BitmapLRUCache lruCacheNew = new BitmapLRUCache(capacity);
lruCacheNew.putAll(this.lruCache);
this.lruCache = lruCacheNew;
} | java | public synchronized void setCapacity(int capacity) {
BitmapLRUCache lruCacheNew = new BitmapLRUCache(capacity);
lruCacheNew.putAll(this.lruCache);
this.lruCache = lruCacheNew;
} | [
"public",
"synchronized",
"void",
"setCapacity",
"(",
"int",
"capacity",
")",
"{",
"BitmapLRUCache",
"lruCacheNew",
"=",
"new",
"BitmapLRUCache",
"(",
"capacity",
")",
";",
"lruCacheNew",
".",
"putAll",
"(",
"this",
".",
"lruCache",
")",
";",
"this",
".",
"lruCache",
"=",
"lruCacheNew",
";",
"}"
] | Sets the new size of this cache. If this cache already contains more items than the new capacity allows, items
are discarded based on the cache policy.
@param capacity the new maximum number of entries in this cache.
@throws IllegalArgumentException if the capacity is negative. | [
"Sets",
"the",
"new",
"size",
"of",
"this",
"cache",
".",
"If",
"this",
"cache",
"already",
"contains",
"more",
"items",
"than",
"the",
"new",
"capacity",
"allows",
"items",
"are",
"discarded",
"based",
"on",
"the",
"cache",
"policy",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/cache/InMemoryTileCache.java#L115-L119 |
28,302 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java | LayerUtil.getUpperLeft | public static Tile getUpperLeft(BoundingBox boundingBox, byte zoomLevel, int tileSize) {
int tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel);
int tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel);
return new Tile(tileLeft, tileTop, zoomLevel, tileSize);
} | java | public static Tile getUpperLeft(BoundingBox boundingBox, byte zoomLevel, int tileSize) {
int tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel);
int tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel);
return new Tile(tileLeft, tileTop, zoomLevel, tileSize);
} | [
"public",
"static",
"Tile",
"getUpperLeft",
"(",
"BoundingBox",
"boundingBox",
",",
"byte",
"zoomLevel",
",",
"int",
"tileSize",
")",
"{",
"int",
"tileLeft",
"=",
"MercatorProjection",
".",
"longitudeToTileX",
"(",
"boundingBox",
".",
"minLongitude",
",",
"zoomLevel",
")",
";",
"int",
"tileTop",
"=",
"MercatorProjection",
".",
"latitudeToTileY",
"(",
"boundingBox",
".",
"maxLatitude",
",",
"zoomLevel",
")",
";",
"return",
"new",
"Tile",
"(",
"tileLeft",
",",
"tileTop",
",",
"zoomLevel",
",",
"tileSize",
")",
";",
"}"
] | Upper left tile for an area.
@param boundingBox the area boundingBox
@param zoomLevel the zoom level.
@param tileSize the tile size.
@return the tile at the upper left of the bbox. | [
"Upper",
"left",
"tile",
"for",
"an",
"area",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java#L64-L68 |
28,303 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java | LayerUtil.getLowerRight | public static Tile getLowerRight(BoundingBox boundingBox, byte zoomLevel, int tileSize) {
int tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel);
int tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel);
return new Tile(tileRight, tileBottom, zoomLevel, tileSize);
} | java | public static Tile getLowerRight(BoundingBox boundingBox, byte zoomLevel, int tileSize) {
int tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel);
int tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel);
return new Tile(tileRight, tileBottom, zoomLevel, tileSize);
} | [
"public",
"static",
"Tile",
"getLowerRight",
"(",
"BoundingBox",
"boundingBox",
",",
"byte",
"zoomLevel",
",",
"int",
"tileSize",
")",
"{",
"int",
"tileRight",
"=",
"MercatorProjection",
".",
"longitudeToTileX",
"(",
"boundingBox",
".",
"maxLongitude",
",",
"zoomLevel",
")",
";",
"int",
"tileBottom",
"=",
"MercatorProjection",
".",
"latitudeToTileY",
"(",
"boundingBox",
".",
"minLatitude",
",",
"zoomLevel",
")",
";",
"return",
"new",
"Tile",
"(",
"tileRight",
",",
"tileBottom",
",",
"zoomLevel",
",",
"tileSize",
")",
";",
"}"
] | Lower right tile for an area.
@param boundingBox the area boundingBox
@param zoomLevel the zoom level.
@param tileSize the tile size.
@return the tile at the lower right of the bbox. | [
"Lower",
"right",
"tile",
"for",
"an",
"area",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java#L78-L82 |
28,304 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java | LayerUtil.collisionFreeOrdered | public static List<MapElementContainer> collisionFreeOrdered(List<MapElementContainer> input) {
// sort items by priority (highest first)
Collections.sort(input, Collections.reverseOrder());
// in order of priority, see if an item can be drawn, i.e. none of the items
// in the currentItemsToDraw list clashes with it.
List<MapElementContainer> output = new LinkedList<MapElementContainer>();
for (MapElementContainer item : input) {
boolean hasSpace = true;
for (MapElementContainer outputElement : output) {
if (outputElement.clashesWith(item)) {
hasSpace = false;
break;
}
}
if (hasSpace) {
output.add(item);
}
}
return output;
} | java | public static List<MapElementContainer> collisionFreeOrdered(List<MapElementContainer> input) {
// sort items by priority (highest first)
Collections.sort(input, Collections.reverseOrder());
// in order of priority, see if an item can be drawn, i.e. none of the items
// in the currentItemsToDraw list clashes with it.
List<MapElementContainer> output = new LinkedList<MapElementContainer>();
for (MapElementContainer item : input) {
boolean hasSpace = true;
for (MapElementContainer outputElement : output) {
if (outputElement.clashesWith(item)) {
hasSpace = false;
break;
}
}
if (hasSpace) {
output.add(item);
}
}
return output;
} | [
"public",
"static",
"List",
"<",
"MapElementContainer",
">",
"collisionFreeOrdered",
"(",
"List",
"<",
"MapElementContainer",
">",
"input",
")",
"{",
"// sort items by priority (highest first)",
"Collections",
".",
"sort",
"(",
"input",
",",
"Collections",
".",
"reverseOrder",
"(",
")",
")",
";",
"// in order of priority, see if an item can be drawn, i.e. none of the items",
"// in the currentItemsToDraw list clashes with it.",
"List",
"<",
"MapElementContainer",
">",
"output",
"=",
"new",
"LinkedList",
"<",
"MapElementContainer",
">",
"(",
")",
";",
"for",
"(",
"MapElementContainer",
"item",
":",
"input",
")",
"{",
"boolean",
"hasSpace",
"=",
"true",
";",
"for",
"(",
"MapElementContainer",
"outputElement",
":",
"output",
")",
"{",
"if",
"(",
"outputElement",
".",
"clashesWith",
"(",
"item",
")",
")",
"{",
"hasSpace",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"hasSpace",
")",
"{",
"output",
".",
"add",
"(",
"item",
")",
";",
"}",
"}",
"return",
"output",
";",
"}"
] | Transforms a list of MapElements, orders it and removes those elements that overlap.
This operation is useful for an early elimination of elements in a list that will never
be drawn because they overlap.
@param input list of MapElements
@return collision-free, ordered list, a subset of the input. | [
"Transforms",
"a",
"list",
"of",
"MapElements",
"orders",
"it",
"and",
"removes",
"those",
"elements",
"that",
"overlap",
".",
"This",
"operation",
"is",
"useful",
"for",
"an",
"early",
"elimination",
"of",
"elements",
"in",
"a",
"list",
"that",
"will",
"never",
"be",
"drawn",
"because",
"they",
"overlap",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/LayerUtil.java#L119-L138 |
28,305 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlUtils.java | XmlUtils.inputStreamFromFile | private static InputStream inputStreamFromFile(String relativePathPrefix, String src) throws IOException {
File file = getFile(relativePathPrefix, src);
if (!file.exists()) {
if (src.length() > 0 && src.charAt(0) == File.separatorChar) {
file = getFile(relativePathPrefix, src.substring(1));
}
if (!file.exists()) {
file = null;
}
} else if (!file.isFile() || !file.canRead()) {
file = null;
}
if (file != null) {
return new FileInputStream(file);
}
return null;
} | java | private static InputStream inputStreamFromFile(String relativePathPrefix, String src) throws IOException {
File file = getFile(relativePathPrefix, src);
if (!file.exists()) {
if (src.length() > 0 && src.charAt(0) == File.separatorChar) {
file = getFile(relativePathPrefix, src.substring(1));
}
if (!file.exists()) {
file = null;
}
} else if (!file.isFile() || !file.canRead()) {
file = null;
}
if (file != null) {
return new FileInputStream(file);
}
return null;
} | [
"private",
"static",
"InputStream",
"inputStreamFromFile",
"(",
"String",
"relativePathPrefix",
",",
"String",
"src",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"getFile",
"(",
"relativePathPrefix",
",",
"src",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"src",
".",
"length",
"(",
")",
">",
"0",
"&&",
"src",
".",
"charAt",
"(",
"0",
")",
"==",
"File",
".",
"separatorChar",
")",
"{",
"file",
"=",
"getFile",
"(",
"relativePathPrefix",
",",
"src",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"file",
"=",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"file",
".",
"isFile",
"(",
")",
"||",
"!",
"file",
".",
"canRead",
"(",
")",
")",
"{",
"file",
"=",
"null",
";",
"}",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"return",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Create InputStream from file resource. | [
"Create",
"InputStream",
"from",
"file",
"resource",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlUtils.java#L208-L224 |
28,306 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlUtils.java | XmlUtils.inputStreamFromJar | private static InputStream inputStreamFromJar(String relativePathPrefix, String src) throws IOException {
String absoluteName = getAbsoluteName(relativePathPrefix, src);
return XmlUtils.class.getResourceAsStream(absoluteName);
} | java | private static InputStream inputStreamFromJar(String relativePathPrefix, String src) throws IOException {
String absoluteName = getAbsoluteName(relativePathPrefix, src);
return XmlUtils.class.getResourceAsStream(absoluteName);
} | [
"private",
"static",
"InputStream",
"inputStreamFromJar",
"(",
"String",
"relativePathPrefix",
",",
"String",
"src",
")",
"throws",
"IOException",
"{",
"String",
"absoluteName",
"=",
"getAbsoluteName",
"(",
"relativePathPrefix",
",",
"src",
")",
";",
"return",
"XmlUtils",
".",
"class",
".",
"getResourceAsStream",
"(",
"absoluteName",
")",
";",
"}"
] | Create InputStream from jar resource. | [
"Create",
"InputStream",
"from",
"jar",
"resource",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/XmlUtils.java#L229-L232 |
28,307 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java | Layers.add | public synchronized void add(int index, Layer layer, boolean redraw) {
checkIsNull(layer);
layer.setDisplayModel(this.displayModel);
this.layersList.add(index, layer);
layer.assign(this.redrawer);
if (redraw) {
this.redrawer.redrawLayers();
}
} | java | public synchronized void add(int index, Layer layer, boolean redraw) {
checkIsNull(layer);
layer.setDisplayModel(this.displayModel);
this.layersList.add(index, layer);
layer.assign(this.redrawer);
if (redraw) {
this.redrawer.redrawLayers();
}
} | [
"public",
"synchronized",
"void",
"add",
"(",
"int",
"index",
",",
"Layer",
"layer",
",",
"boolean",
"redraw",
")",
"{",
"checkIsNull",
"(",
"layer",
")",
";",
"layer",
".",
"setDisplayModel",
"(",
"this",
".",
"displayModel",
")",
";",
"this",
".",
"layersList",
".",
"add",
"(",
"index",
",",
"layer",
")",
";",
"layer",
".",
"assign",
"(",
"this",
".",
"redrawer",
")",
";",
"if",
"(",
"redraw",
")",
"{",
"this",
".",
"redrawer",
".",
"redrawLayers",
"(",
")",
";",
"}",
"}"
] | Adds a new layer at the specified position.
@param index The position at which to add the new layer (the lowest layer has position 0)
@param layer The new layer to add
@param redraw Whether the map should be redrawn after adding the layer
@see List#add(int, Object) | [
"Adds",
"a",
"new",
"layer",
"at",
"the",
"specified",
"position",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java#L81-L89 |
28,308 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java | Layers.addAll | public synchronized void addAll(Collection<Layer> layers, boolean redraw) {
checkIsNull(layers);
for (Layer layer : layers) {
layer.setDisplayModel(this.displayModel);
}
this.layersList.addAll(layers);
for (Layer layer : layers) {
layer.assign(this.redrawer);
}
if (redraw) {
this.redrawer.redrawLayers();
}
} | java | public synchronized void addAll(Collection<Layer> layers, boolean redraw) {
checkIsNull(layers);
for (Layer layer : layers) {
layer.setDisplayModel(this.displayModel);
}
this.layersList.addAll(layers);
for (Layer layer : layers) {
layer.assign(this.redrawer);
}
if (redraw) {
this.redrawer.redrawLayers();
}
} | [
"public",
"synchronized",
"void",
"addAll",
"(",
"Collection",
"<",
"Layer",
">",
"layers",
",",
"boolean",
"redraw",
")",
"{",
"checkIsNull",
"(",
"layers",
")",
";",
"for",
"(",
"Layer",
"layer",
":",
"layers",
")",
"{",
"layer",
".",
"setDisplayModel",
"(",
"this",
".",
"displayModel",
")",
";",
"}",
"this",
".",
"layersList",
".",
"addAll",
"(",
"layers",
")",
";",
"for",
"(",
"Layer",
"layer",
":",
"layers",
")",
"{",
"layer",
".",
"assign",
"(",
"this",
".",
"redrawer",
")",
";",
"}",
"if",
"(",
"redraw",
")",
"{",
"this",
".",
"redrawer",
".",
"redrawLayers",
"(",
")",
";",
"}",
"}"
] | Adds multiple new layers on top.
@param layers The new layers to add
@param redraw Whether the map should be redrawn after adding the layers
@see List#addAll(Collection) | [
"Adds",
"multiple",
"new",
"layers",
"on",
"top",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java#L142-L154 |
28,309 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java | Layers.clear | public synchronized void clear(boolean redraw) {
for (Layer layer : this.layersList) {
layer.unassign();
}
this.layersList.clear();
if (redraw) {
this.redrawer.redrawLayers();
}
} | java | public synchronized void clear(boolean redraw) {
for (Layer layer : this.layersList) {
layer.unassign();
}
this.layersList.clear();
if (redraw) {
this.redrawer.redrawLayers();
}
} | [
"public",
"synchronized",
"void",
"clear",
"(",
"boolean",
"redraw",
")",
"{",
"for",
"(",
"Layer",
"layer",
":",
"this",
".",
"layersList",
")",
"{",
"layer",
".",
"unassign",
"(",
")",
";",
"}",
"this",
".",
"layersList",
".",
"clear",
"(",
")",
";",
"if",
"(",
"redraw",
")",
"{",
"this",
".",
"redrawer",
".",
"redrawLayers",
"(",
")",
";",
"}",
"}"
] | Removes all layers.
@param redraw Whether the map should be redrawn after removing the layers
@see List#clear() | [
"Removes",
"all",
"layers",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/Layers.java#L208-L216 |
28,310 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteQuery.java | SQLiteQuery.fillWindow | int fillWindow(CursorWindow window, int startPos, int requiredPos, boolean countAllRows) {
acquireReference();
try {
window.acquireReference();
try {
int numRows = getSession().executeForCursorWindow(getSql(), getBindArgs(),
window, startPos, requiredPos, countAllRows, getConnectionFlags(),
mCancellationSignal);
return numRows;
} catch (SQLiteDatabaseCorruptException ex) {
onCorruption();
throw ex;
} catch (SQLiteException ex) {
Log.e(TAG, "exception: " + ex.getMessage() + "; query: " + getSql());
throw ex;
} finally {
window.releaseReference();
}
} finally {
releaseReference();
}
} | java | int fillWindow(CursorWindow window, int startPos, int requiredPos, boolean countAllRows) {
acquireReference();
try {
window.acquireReference();
try {
int numRows = getSession().executeForCursorWindow(getSql(), getBindArgs(),
window, startPos, requiredPos, countAllRows, getConnectionFlags(),
mCancellationSignal);
return numRows;
} catch (SQLiteDatabaseCorruptException ex) {
onCorruption();
throw ex;
} catch (SQLiteException ex) {
Log.e(TAG, "exception: " + ex.getMessage() + "; query: " + getSql());
throw ex;
} finally {
window.releaseReference();
}
} finally {
releaseReference();
}
} | [
"int",
"fillWindow",
"(",
"CursorWindow",
"window",
",",
"int",
"startPos",
",",
"int",
"requiredPos",
",",
"boolean",
"countAllRows",
")",
"{",
"acquireReference",
"(",
")",
";",
"try",
"{",
"window",
".",
"acquireReference",
"(",
")",
";",
"try",
"{",
"int",
"numRows",
"=",
"getSession",
"(",
")",
".",
"executeForCursorWindow",
"(",
"getSql",
"(",
")",
",",
"getBindArgs",
"(",
")",
",",
"window",
",",
"startPos",
",",
"requiredPos",
",",
"countAllRows",
",",
"getConnectionFlags",
"(",
")",
",",
"mCancellationSignal",
")",
";",
"return",
"numRows",
";",
"}",
"catch",
"(",
"SQLiteDatabaseCorruptException",
"ex",
")",
"{",
"onCorruption",
"(",
")",
";",
"throw",
"ex",
";",
"}",
"catch",
"(",
"SQLiteException",
"ex",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"exception: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
"+",
"\"; query: \"",
"+",
"getSql",
"(",
")",
")",
";",
"throw",
"ex",
";",
"}",
"finally",
"{",
"window",
".",
"releaseReference",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"releaseReference",
"(",
")",
";",
"}",
"}"
] | Reads rows into a buffer.
@param window The window to fill into
@param startPos The start position for filling the window.
@param requiredPos The position of a row that MUST be in the window.
If it won't fit, then the query should discard part of what it filled.
@param countAllRows True to count all rows that the query would
return regardless of whether they fit in the window.
@return Number of rows that were enumerated. Might not be all rows
unless countAllRows is true.
@throws SQLiteException if an error occurs.
@throws OperationCanceledException if the operation was canceled. | [
"Reads",
"rows",
"into",
"a",
"buffer",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteQuery.java#L61-L82 |
28,311 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java | TileDependencies.getOverlappingElements | Set<MapElementContainer> getOverlappingElements(Tile from, Tile to) {
if (overlapData.containsKey(from) && overlapData.get(from).containsKey(to)) {
return overlapData.get(from).get(to);
}
return new HashSet<MapElementContainer>(0);
} | java | Set<MapElementContainer> getOverlappingElements(Tile from, Tile to) {
if (overlapData.containsKey(from) && overlapData.get(from).containsKey(to)) {
return overlapData.get(from).get(to);
}
return new HashSet<MapElementContainer>(0);
} | [
"Set",
"<",
"MapElementContainer",
">",
"getOverlappingElements",
"(",
"Tile",
"from",
",",
"Tile",
"to",
")",
"{",
"if",
"(",
"overlapData",
".",
"containsKey",
"(",
"from",
")",
"&&",
"overlapData",
".",
"get",
"(",
"from",
")",
".",
"containsKey",
"(",
"to",
")",
")",
"{",
"return",
"overlapData",
".",
"get",
"(",
"from",
")",
".",
"get",
"(",
"to",
")",
";",
"}",
"return",
"new",
"HashSet",
"<",
"MapElementContainer",
">",
"(",
"0",
")",
";",
"}"
] | Retrieves the overlap data from the neighbouring tiles
@param from the origin tile
@param to the tile the label clashesWith to
@return a List of the elements | [
"Retrieves",
"the",
"overlap",
"data",
"from",
"the",
"neighbouring",
"tiles"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java#L58-L63 |
28,312 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java | TileDependencies.removeTileData | void removeTileData(Tile from, Tile to) {
if (overlapData.containsKey(from)) {
overlapData.get(from).remove(to);
}
} | java | void removeTileData(Tile from, Tile to) {
if (overlapData.containsKey(from)) {
overlapData.get(from).remove(to);
}
} | [
"void",
"removeTileData",
"(",
"Tile",
"from",
",",
"Tile",
"to",
")",
"{",
"if",
"(",
"overlapData",
".",
"containsKey",
"(",
"from",
")",
")",
"{",
"overlapData",
".",
"get",
"(",
"from",
")",
".",
"remove",
"(",
"to",
")",
";",
"}",
"}"
] | Cache maintenance operation to remove data for a tile from the cache. This should be excuted
if a tile is removed from the TileCache and will be drawn again.
@param from | [
"Cache",
"maintenance",
"operation",
"to",
"remove",
"data",
"for",
"a",
"tile",
"from",
"the",
"cache",
".",
"This",
"should",
"be",
"excuted",
"if",
"a",
"tile",
"is",
"removed",
"from",
"the",
"TileCache",
"and",
"will",
"be",
"drawn",
"again",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java#L81-L86 |
28,313 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java | MapViewProjection.fromPixels | public LatLong fromPixels(double x, double y) {
if (this.mapView.getWidth() <= 0 || this.mapView.getHeight() <= 0) {
return null;
}
// this uses the framebuffer position, the mapview position can be out of sync with
// what the user sees on the screen if an animation is in progress
MapPosition mapPosition = this.mapView.getModel().frameBufferModel.getMapPosition();
// this means somehow the mapview is not yet properly set up, see issue #308.
if (mapPosition == null) {
return null;
}
// calculate the pixel coordinates of the top left corner
LatLong latLong = mapPosition.latLong;
long mapSize = MercatorProjection.getMapSize(mapPosition.zoomLevel, this.mapView.getModel().displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(latLong.longitude, mapSize);
double pixelY = MercatorProjection.latitudeToPixelY(latLong.latitude, mapSize);
pixelX -= this.mapView.getWidth() >> 1;
pixelY -= this.mapView.getHeight() >> 1;
// catch outer map limits
try {
// convert the pixel coordinates to a LatLong and return it
return new LatLong(MercatorProjection.pixelYToLatitude(pixelY + y, mapSize),
MercatorProjection.pixelXToLongitude(pixelX + x, mapSize));
} catch (Exception e) {
return null;
}
} | java | public LatLong fromPixels(double x, double y) {
if (this.mapView.getWidth() <= 0 || this.mapView.getHeight() <= 0) {
return null;
}
// this uses the framebuffer position, the mapview position can be out of sync with
// what the user sees on the screen if an animation is in progress
MapPosition mapPosition = this.mapView.getModel().frameBufferModel.getMapPosition();
// this means somehow the mapview is not yet properly set up, see issue #308.
if (mapPosition == null) {
return null;
}
// calculate the pixel coordinates of the top left corner
LatLong latLong = mapPosition.latLong;
long mapSize = MercatorProjection.getMapSize(mapPosition.zoomLevel, this.mapView.getModel().displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(latLong.longitude, mapSize);
double pixelY = MercatorProjection.latitudeToPixelY(latLong.latitude, mapSize);
pixelX -= this.mapView.getWidth() >> 1;
pixelY -= this.mapView.getHeight() >> 1;
// catch outer map limits
try {
// convert the pixel coordinates to a LatLong and return it
return new LatLong(MercatorProjection.pixelYToLatitude(pixelY + y, mapSize),
MercatorProjection.pixelXToLongitude(pixelX + x, mapSize));
} catch (Exception e) {
return null;
}
} | [
"public",
"LatLong",
"fromPixels",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"if",
"(",
"this",
".",
"mapView",
".",
"getWidth",
"(",
")",
"<=",
"0",
"||",
"this",
".",
"mapView",
".",
"getHeight",
"(",
")",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// this uses the framebuffer position, the mapview position can be out of sync with",
"// what the user sees on the screen if an animation is in progress",
"MapPosition",
"mapPosition",
"=",
"this",
".",
"mapView",
".",
"getModel",
"(",
")",
".",
"frameBufferModel",
".",
"getMapPosition",
"(",
")",
";",
"// this means somehow the mapview is not yet properly set up, see issue #308.",
"if",
"(",
"mapPosition",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// calculate the pixel coordinates of the top left corner",
"LatLong",
"latLong",
"=",
"mapPosition",
".",
"latLong",
";",
"long",
"mapSize",
"=",
"MercatorProjection",
".",
"getMapSize",
"(",
"mapPosition",
".",
"zoomLevel",
",",
"this",
".",
"mapView",
".",
"getModel",
"(",
")",
".",
"displayModel",
".",
"getTileSize",
"(",
")",
")",
";",
"double",
"pixelX",
"=",
"MercatorProjection",
".",
"longitudeToPixelX",
"(",
"latLong",
".",
"longitude",
",",
"mapSize",
")",
";",
"double",
"pixelY",
"=",
"MercatorProjection",
".",
"latitudeToPixelY",
"(",
"latLong",
".",
"latitude",
",",
"mapSize",
")",
";",
"pixelX",
"-=",
"this",
".",
"mapView",
".",
"getWidth",
"(",
")",
">>",
"1",
";",
"pixelY",
"-=",
"this",
".",
"mapView",
".",
"getHeight",
"(",
")",
">>",
"1",
";",
"// catch outer map limits",
"try",
"{",
"// convert the pixel coordinates to a LatLong and return it",
"return",
"new",
"LatLong",
"(",
"MercatorProjection",
".",
"pixelYToLatitude",
"(",
"pixelY",
"+",
"y",
",",
"mapSize",
")",
",",
"MercatorProjection",
".",
"pixelXToLongitude",
"(",
"pixelX",
"+",
"x",
",",
"mapSize",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Computes the geographic coordinates of a screen point.
@return the coordinates of the x/y point | [
"Computes",
"the",
"geographic",
"coordinates",
"of",
"a",
"screen",
"point",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java#L39-L69 |
28,314 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java | MapViewProjection.getLatitudeSpan | public double getLatitudeSpan() {
if (this.mapView.getWidth() > 0 && this.mapView.getHeight() > 0) {
LatLong top = fromPixels(0, 0);
LatLong bottom = fromPixels(0, this.mapView.getHeight());
return Math.abs(top.latitude - bottom.latitude);
}
throw new IllegalStateException(INVALID_MAP_VIEW_DIMENSIONS);
} | java | public double getLatitudeSpan() {
if (this.mapView.getWidth() > 0 && this.mapView.getHeight() > 0) {
LatLong top = fromPixels(0, 0);
LatLong bottom = fromPixels(0, this.mapView.getHeight());
return Math.abs(top.latitude - bottom.latitude);
}
throw new IllegalStateException(INVALID_MAP_VIEW_DIMENSIONS);
} | [
"public",
"double",
"getLatitudeSpan",
"(",
")",
"{",
"if",
"(",
"this",
".",
"mapView",
".",
"getWidth",
"(",
")",
">",
"0",
"&&",
"this",
".",
"mapView",
".",
"getHeight",
"(",
")",
">",
"0",
")",
"{",
"LatLong",
"top",
"=",
"fromPixels",
"(",
"0",
",",
"0",
")",
";",
"LatLong",
"bottom",
"=",
"fromPixels",
"(",
"0",
",",
"this",
".",
"mapView",
".",
"getHeight",
"(",
")",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"top",
".",
"latitude",
"-",
"bottom",
".",
"latitude",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"INVALID_MAP_VIEW_DIMENSIONS",
")",
";",
"}"
] | Computes vertical extend of the map view.
@return the latitude span of the map in degrees | [
"Computes",
"vertical",
"extend",
"of",
"the",
"map",
"view",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java#L76-L83 |
28,315 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java | MapViewProjection.getLongitudeSpan | public double getLongitudeSpan() {
if (this.mapView.getWidth() > 0 && this.mapView.getHeight() > 0) {
LatLong left = fromPixels(0, 0);
LatLong right = fromPixels(this.mapView.getWidth(), 0);
return Math.abs(left.longitude - right.longitude);
}
throw new IllegalStateException(INVALID_MAP_VIEW_DIMENSIONS);
} | java | public double getLongitudeSpan() {
if (this.mapView.getWidth() > 0 && this.mapView.getHeight() > 0) {
LatLong left = fromPixels(0, 0);
LatLong right = fromPixels(this.mapView.getWidth(), 0);
return Math.abs(left.longitude - right.longitude);
}
throw new IllegalStateException(INVALID_MAP_VIEW_DIMENSIONS);
} | [
"public",
"double",
"getLongitudeSpan",
"(",
")",
"{",
"if",
"(",
"this",
".",
"mapView",
".",
"getWidth",
"(",
")",
">",
"0",
"&&",
"this",
".",
"mapView",
".",
"getHeight",
"(",
")",
">",
"0",
")",
"{",
"LatLong",
"left",
"=",
"fromPixels",
"(",
"0",
",",
"0",
")",
";",
"LatLong",
"right",
"=",
"fromPixels",
"(",
"this",
".",
"mapView",
".",
"getWidth",
"(",
")",
",",
"0",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"left",
".",
"longitude",
"-",
"right",
".",
"longitude",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"INVALID_MAP_VIEW_DIMENSIONS",
")",
";",
"}"
] | Computes horizontal extend of the map view.
@return the longitude span of the map in degrees | [
"Computes",
"horizontal",
"extend",
"of",
"the",
"map",
"view",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/util/MapViewProjection.java#L90-L97 |
28,316 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java | LineSegment.angleTo | public double angleTo(LineSegment other) {
double angle1 = Math.atan2(this.start.y - this.end.y, this.start.x - this.end.x);
double angle2 = Math.atan2(other.start.y - other.end.y, other.start.x - other.end.x);
double angle = Math.toDegrees(angle1 - angle2);
if (angle <= -180) {
angle += 360;
}
if (angle >= 180) {
angle -= 360;
}
return angle;
} | java | public double angleTo(LineSegment other) {
double angle1 = Math.atan2(this.start.y - this.end.y, this.start.x - this.end.x);
double angle2 = Math.atan2(other.start.y - other.end.y, other.start.x - other.end.x);
double angle = Math.toDegrees(angle1 - angle2);
if (angle <= -180) {
angle += 360;
}
if (angle >= 180) {
angle -= 360;
}
return angle;
} | [
"public",
"double",
"angleTo",
"(",
"LineSegment",
"other",
")",
"{",
"double",
"angle1",
"=",
"Math",
".",
"atan2",
"(",
"this",
".",
"start",
".",
"y",
"-",
"this",
".",
"end",
".",
"y",
",",
"this",
".",
"start",
".",
"x",
"-",
"this",
".",
"end",
".",
"x",
")",
";",
"double",
"angle2",
"=",
"Math",
".",
"atan2",
"(",
"other",
".",
"start",
".",
"y",
"-",
"other",
".",
"end",
".",
"y",
",",
"other",
".",
"start",
".",
"x",
"-",
"other",
".",
"end",
".",
"x",
")",
";",
"double",
"angle",
"=",
"Math",
".",
"toDegrees",
"(",
"angle1",
"-",
"angle2",
")",
";",
"if",
"(",
"angle",
"<=",
"-",
"180",
")",
"{",
"angle",
"+=",
"360",
";",
"}",
"if",
"(",
"angle",
">=",
"180",
")",
"{",
"angle",
"-=",
"360",
";",
"}",
"return",
"angle",
";",
"}"
] | Computes the angle between this LineSegment and another one.
@param other the other LineSegment
@return angle in degrees | [
"Computes",
"the",
"angle",
"between",
"this",
"LineSegment",
"and",
"another",
"one",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java#L61-L72 |
28,317 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java | LineSegment.intersectsRectangle | public boolean intersectsRectangle(Rectangle r, boolean bias) {
int codeStart = code(r, this.start);
int codeEnd = code(r, this.end);
if (0 == (codeStart | codeEnd)) {
// both points are inside, trivial case
return true;
} else if (0 != (codeStart & codeEnd)) {
// both points are either below, above, left or right of the box, no intersection
return false;
}
return bias;
} | java | public boolean intersectsRectangle(Rectangle r, boolean bias) {
int codeStart = code(r, this.start);
int codeEnd = code(r, this.end);
if (0 == (codeStart | codeEnd)) {
// both points are inside, trivial case
return true;
} else if (0 != (codeStart & codeEnd)) {
// both points are either below, above, left or right of the box, no intersection
return false;
}
return bias;
} | [
"public",
"boolean",
"intersectsRectangle",
"(",
"Rectangle",
"r",
",",
"boolean",
"bias",
")",
"{",
"int",
"codeStart",
"=",
"code",
"(",
"r",
",",
"this",
".",
"start",
")",
";",
"int",
"codeEnd",
"=",
"code",
"(",
"r",
",",
"this",
".",
"end",
")",
";",
"if",
"(",
"0",
"==",
"(",
"codeStart",
"|",
"codeEnd",
")",
")",
"{",
"// both points are inside, trivial case",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"0",
"!=",
"(",
"codeStart",
"&",
"codeEnd",
")",
")",
"{",
"// both points are either below, above, left or right of the box, no intersection",
"return",
"false",
";",
"}",
"return",
"bias",
";",
"}"
] | Returns a fast computation if the line intersects the rectangle or bias if there
is no fast way to compute the intersection.
@param r retangle to test
@param bias the result if no fast computation is possible
@return either the fast and correct result or the bias (which might be wrong). | [
"Returns",
"a",
"fast",
"computation",
"if",
"the",
"line",
"intersects",
"the",
"rectangle",
"or",
"bias",
"if",
"there",
"is",
"no",
"fast",
"way",
"to",
"compute",
"the",
"intersection",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java#L167-L179 |
28,318 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java | LineSegment.pointAlongLineSegment | public Point pointAlongLineSegment(double distance) {
if (start.x == end.x) {
// we have a vertical line
if (start.y > end.y) {
return new Point(end.x, end.y + distance);
} else {
return new Point(start.x, start.y + distance);
}
} else {
double slope = (end.y - start.y) / (end.x - start.x);
double dx = Math.sqrt((distance * distance) / (1 + (slope * slope)));
if (end.x < start.x) {
dx *= -1;
}
return new Point(start.x + dx, start.y + slope * dx);
}
} | java | public Point pointAlongLineSegment(double distance) {
if (start.x == end.x) {
// we have a vertical line
if (start.y > end.y) {
return new Point(end.x, end.y + distance);
} else {
return new Point(start.x, start.y + distance);
}
} else {
double slope = (end.y - start.y) / (end.x - start.x);
double dx = Math.sqrt((distance * distance) / (1 + (slope * slope)));
if (end.x < start.x) {
dx *= -1;
}
return new Point(start.x + dx, start.y + slope * dx);
}
} | [
"public",
"Point",
"pointAlongLineSegment",
"(",
"double",
"distance",
")",
"{",
"if",
"(",
"start",
".",
"x",
"==",
"end",
".",
"x",
")",
"{",
"// we have a vertical line",
"if",
"(",
"start",
".",
"y",
">",
"end",
".",
"y",
")",
"{",
"return",
"new",
"Point",
"(",
"end",
".",
"x",
",",
"end",
".",
"y",
"+",
"distance",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Point",
"(",
"start",
".",
"x",
",",
"start",
".",
"y",
"+",
"distance",
")",
";",
"}",
"}",
"else",
"{",
"double",
"slope",
"=",
"(",
"end",
".",
"y",
"-",
"start",
".",
"y",
")",
"/",
"(",
"end",
".",
"x",
"-",
"start",
".",
"x",
")",
";",
"double",
"dx",
"=",
"Math",
".",
"sqrt",
"(",
"(",
"distance",
"*",
"distance",
")",
"/",
"(",
"1",
"+",
"(",
"slope",
"*",
"slope",
")",
")",
")",
";",
"if",
"(",
"end",
".",
"x",
"<",
"start",
".",
"x",
")",
"{",
"dx",
"*=",
"-",
"1",
";",
"}",
"return",
"new",
"Point",
"(",
"start",
".",
"x",
"+",
"dx",
",",
"start",
".",
"y",
"+",
"slope",
"*",
"dx",
")",
";",
"}",
"}"
] | Computes a Point along the line segment with a given distance to the start Point.
@param distance distance from start point
@return point at given distance from start point | [
"Computes",
"a",
"Point",
"along",
"the",
"line",
"segment",
"with",
"a",
"given",
"distance",
"to",
"the",
"start",
"Point",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java#L197-L213 |
28,319 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java | LineSegment.subSegment | public LineSegment subSegment(double offset, double length) {
Point subSegmentStart = pointAlongLineSegment(offset);
Point subSegmentEnd = pointAlongLineSegment(offset + length);
return new LineSegment(subSegmentStart, subSegmentEnd);
} | java | public LineSegment subSegment(double offset, double length) {
Point subSegmentStart = pointAlongLineSegment(offset);
Point subSegmentEnd = pointAlongLineSegment(offset + length);
return new LineSegment(subSegmentStart, subSegmentEnd);
} | [
"public",
"LineSegment",
"subSegment",
"(",
"double",
"offset",
",",
"double",
"length",
")",
"{",
"Point",
"subSegmentStart",
"=",
"pointAlongLineSegment",
"(",
"offset",
")",
";",
"Point",
"subSegmentEnd",
"=",
"pointAlongLineSegment",
"(",
"offset",
"+",
"length",
")",
";",
"return",
"new",
"LineSegment",
"(",
"subSegmentStart",
",",
"subSegmentEnd",
")",
";",
"}"
] | LineSegment that starts at offset from start and runs for length towards end point
@param offset offset applied at begin of line
@param length length of the new segment
@return new LineSegment computed | [
"LineSegment",
"that",
"starts",
"at",
"offset",
"from",
"start",
"and",
"runs",
"for",
"length",
"towards",
"end",
"point"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LineSegment.java#L231-L235 |
28,320 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/ReadBuffer.java | ReadBuffer.readFromFile | public boolean readFromFile(int length) throws IOException {
// ensure that the read buffer is large enough
if (this.bufferData == null || this.bufferData.length < length) {
// ensure that the read buffer is not too large
if (length > Parameters.MAXIMUM_BUFFER_SIZE) {
LOGGER.warning("invalid read length: " + length);
return false;
}
this.bufferData = new byte[length];
this.bufferWrapper = ByteBuffer.wrap(this.bufferData, 0, length);
}
// reset the buffer position and read the data into the buffer
this.bufferPosition = 0;
this.bufferWrapper.clear();
return this.inputChannel.read(this.bufferWrapper) == length;
} | java | public boolean readFromFile(int length) throws IOException {
// ensure that the read buffer is large enough
if (this.bufferData == null || this.bufferData.length < length) {
// ensure that the read buffer is not too large
if (length > Parameters.MAXIMUM_BUFFER_SIZE) {
LOGGER.warning("invalid read length: " + length);
return false;
}
this.bufferData = new byte[length];
this.bufferWrapper = ByteBuffer.wrap(this.bufferData, 0, length);
}
// reset the buffer position and read the data into the buffer
this.bufferPosition = 0;
this.bufferWrapper.clear();
return this.inputChannel.read(this.bufferWrapper) == length;
} | [
"public",
"boolean",
"readFromFile",
"(",
"int",
"length",
")",
"throws",
"IOException",
"{",
"// ensure that the read buffer is large enough",
"if",
"(",
"this",
".",
"bufferData",
"==",
"null",
"||",
"this",
".",
"bufferData",
".",
"length",
"<",
"length",
")",
"{",
"// ensure that the read buffer is not too large",
"if",
"(",
"length",
">",
"Parameters",
".",
"MAXIMUM_BUFFER_SIZE",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"invalid read length: \"",
"+",
"length",
")",
";",
"return",
"false",
";",
"}",
"this",
".",
"bufferData",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"this",
".",
"bufferWrapper",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"this",
".",
"bufferData",
",",
"0",
",",
"length",
")",
";",
"}",
"// reset the buffer position and read the data into the buffer",
"this",
".",
"bufferPosition",
"=",
"0",
";",
"this",
".",
"bufferWrapper",
".",
"clear",
"(",
")",
";",
"return",
"this",
".",
"inputChannel",
".",
"read",
"(",
"this",
".",
"bufferWrapper",
")",
"==",
"length",
";",
"}"
] | Reads the given amount of bytes from the file into the read buffer and resets the internal buffer position. If
the capacity of the read buffer is too small, a larger one is created automatically.
@param length the amount of bytes to read from the file.
@return true if the whole data was read successfully, false otherwise.
@throws IOException if an error occurs while reading the file. | [
"Reads",
"the",
"given",
"amount",
"of",
"bytes",
"from",
"the",
"file",
"into",
"the",
"read",
"buffer",
"and",
"resets",
"the",
"internal",
"buffer",
"position",
".",
"If",
"the",
"capacity",
"of",
"the",
"read",
"buffer",
"is",
"too",
"small",
"a",
"larger",
"one",
"is",
"created",
"automatically",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/ReadBuffer.java#L80-L97 |
28,321 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/ReadBuffer.java | ReadBuffer.readUTF8EncodedString | public String readUTF8EncodedString(int stringLength) {
if (stringLength > 0 && this.bufferPosition + stringLength <= this.bufferData.length) {
this.bufferPosition += stringLength;
try {
return new String(this.bufferData, this.bufferPosition - stringLength, stringLength, CHARSET_UTF8);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
LOGGER.warning("invalid string length: " + stringLength);
return null;
} | java | public String readUTF8EncodedString(int stringLength) {
if (stringLength > 0 && this.bufferPosition + stringLength <= this.bufferData.length) {
this.bufferPosition += stringLength;
try {
return new String(this.bufferData, this.bufferPosition - stringLength, stringLength, CHARSET_UTF8);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
LOGGER.warning("invalid string length: " + stringLength);
return null;
} | [
"public",
"String",
"readUTF8EncodedString",
"(",
"int",
"stringLength",
")",
"{",
"if",
"(",
"stringLength",
">",
"0",
"&&",
"this",
".",
"bufferPosition",
"+",
"stringLength",
"<=",
"this",
".",
"bufferData",
".",
"length",
")",
"{",
"this",
".",
"bufferPosition",
"+=",
"stringLength",
";",
"try",
"{",
"return",
"new",
"String",
"(",
"this",
".",
"bufferData",
",",
"this",
".",
"bufferPosition",
"-",
"stringLength",
",",
"stringLength",
",",
"CHARSET_UTF8",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
"LOGGER",
".",
"warning",
"(",
"\"invalid string length: \"",
"+",
"stringLength",
")",
";",
"return",
"null",
";",
"}"
] | Decodes the given amount of bytes from the read buffer to a string.
@param stringLength the length of the string in bytes.
@return the UTF-8 decoded string (may be null). | [
"Decodes",
"the",
"given",
"amount",
"of",
"bytes",
"from",
"the",
"read",
"buffer",
"to",
"a",
"string",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/ReadBuffer.java#L272-L283 |
28,322 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/CanvasRasterer.java | CanvasRasterer.fillOutsideAreas | void fillOutsideAreas(int color, Rectangle insideArea) {
this.canvas.setClipDifference((int) insideArea.left, (int) insideArea.top, (int) insideArea.getWidth(), (int) insideArea.getHeight());
this.canvas.fillColor(color);
this.canvas.resetClip();
} | java | void fillOutsideAreas(int color, Rectangle insideArea) {
this.canvas.setClipDifference((int) insideArea.left, (int) insideArea.top, (int) insideArea.getWidth(), (int) insideArea.getHeight());
this.canvas.fillColor(color);
this.canvas.resetClip();
} | [
"void",
"fillOutsideAreas",
"(",
"int",
"color",
",",
"Rectangle",
"insideArea",
")",
"{",
"this",
".",
"canvas",
".",
"setClipDifference",
"(",
"(",
"int",
")",
"insideArea",
".",
"left",
",",
"(",
"int",
")",
"insideArea",
".",
"top",
",",
"(",
"int",
")",
"insideArea",
".",
"getWidth",
"(",
")",
",",
"(",
"int",
")",
"insideArea",
".",
"getHeight",
"(",
")",
")",
";",
"this",
".",
"canvas",
".",
"fillColor",
"(",
"color",
")",
";",
"this",
".",
"canvas",
".",
"resetClip",
"(",
")",
";",
"}"
] | Fills the area outside the specificed rectangle with color.
This method is used to blank out areas that fall outside the map area.
@param color the fill color for the outside area
@param insideArea the inside area on which not to draw | [
"Fills",
"the",
"area",
"outside",
"the",
"specificed",
"rectangle",
"with",
"color",
".",
"This",
"method",
"is",
"used",
"to",
"blank",
"out",
"areas",
"that",
"fall",
"outside",
"the",
"map",
"area",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/CanvasRasterer.java#L112-L116 |
28,323 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/hills/DiffuseLightShadingAlgorithm.java | DiffuseLightShadingAlgorithm.calculateRaw | double calculateRaw(double n, double e) {
// calculate the distance of the normal vector to a plane orthogonal to the light source and passing through zero,
// the fraction of distance to vector lenght is proportional to the amount of light that would be hitting a disc
// orthogonal to the normal vector
double normPlaneDist = (e + n + a) / (ast2 * Math.sqrt(n * n + e * e + 1));
double lightness = Math.max(0, normPlaneDist);
return lightness;
} | java | double calculateRaw(double n, double e) {
// calculate the distance of the normal vector to a plane orthogonal to the light source and passing through zero,
// the fraction of distance to vector lenght is proportional to the amount of light that would be hitting a disc
// orthogonal to the normal vector
double normPlaneDist = (e + n + a) / (ast2 * Math.sqrt(n * n + e * e + 1));
double lightness = Math.max(0, normPlaneDist);
return lightness;
} | [
"double",
"calculateRaw",
"(",
"double",
"n",
",",
"double",
"e",
")",
"{",
"// calculate the distance of the normal vector to a plane orthogonal to the light source and passing through zero,",
"// the fraction of distance to vector lenght is proportional to the amount of light that would be hitting a disc",
"// orthogonal to the normal vector",
"double",
"normPlaneDist",
"=",
"(",
"e",
"+",
"n",
"+",
"a",
")",
"/",
"(",
"ast2",
"*",
"Math",
".",
"sqrt",
"(",
"n",
"*",
"n",
"+",
"e",
"*",
"e",
"+",
"1",
")",
")",
";",
"double",
"lightness",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"normPlaneDist",
")",
";",
"return",
"lightness",
";",
"}"
] | return 0..1 | [
"return",
"0",
"..",
"1"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/hills/DiffuseLightShadingAlgorithm.java#L194-L202 |
28,324 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/IndexCache.java | IndexCache.getIndexEntry | long getIndexEntry(SubFileParameter subFileParameter, long blockNumber) throws IOException {
// check if the block number is out of bounds
if (blockNumber >= subFileParameter.numberOfBlocks) {
throw new IOException("invalid block number: " + blockNumber);
}
// calculate the index block number
long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK;
// create the cache entry key for this request
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter, indexBlockNumber);
// check for cached index block
byte[] indexBlock = this.map.get(indexCacheEntryKey);
if (indexBlock == null) {
// cache miss, seek to the correct index block in the file and read it
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber * SIZE_OF_INDEX_BLOCK;
int remainingIndexSize = (int) (subFileParameter.indexEndAddress - indexBlockPosition);
int indexBlockSize = Math.min(SIZE_OF_INDEX_BLOCK, remainingIndexSize);
indexBlock = new byte[indexBlockSize];
ByteBuffer indexBlockWrapper = ByteBuffer.wrap(indexBlock, 0, indexBlockSize);
synchronized (this.fileChannel) {
this.fileChannel.position(indexBlockPosition);
if (this.fileChannel.read(indexBlockWrapper) != indexBlockSize) {
throw new IOException("could not read index block with size: " + indexBlockSize);
}
}
// put the index block in the map
this.map.put(indexCacheEntryKey, indexBlock);
}
// calculate the address of the index entry inside the index block
long indexEntryInBlock = blockNumber % INDEX_ENTRIES_PER_BLOCK;
int addressInIndexBlock = (int) (indexEntryInBlock * SubFileParameter.BYTES_PER_INDEX_ENTRY);
// return the real index entry
return Deserializer.getFiveBytesLong(indexBlock, addressInIndexBlock);
} | java | long getIndexEntry(SubFileParameter subFileParameter, long blockNumber) throws IOException {
// check if the block number is out of bounds
if (blockNumber >= subFileParameter.numberOfBlocks) {
throw new IOException("invalid block number: " + blockNumber);
}
// calculate the index block number
long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK;
// create the cache entry key for this request
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter, indexBlockNumber);
// check for cached index block
byte[] indexBlock = this.map.get(indexCacheEntryKey);
if (indexBlock == null) {
// cache miss, seek to the correct index block in the file and read it
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber * SIZE_OF_INDEX_BLOCK;
int remainingIndexSize = (int) (subFileParameter.indexEndAddress - indexBlockPosition);
int indexBlockSize = Math.min(SIZE_OF_INDEX_BLOCK, remainingIndexSize);
indexBlock = new byte[indexBlockSize];
ByteBuffer indexBlockWrapper = ByteBuffer.wrap(indexBlock, 0, indexBlockSize);
synchronized (this.fileChannel) {
this.fileChannel.position(indexBlockPosition);
if (this.fileChannel.read(indexBlockWrapper) != indexBlockSize) {
throw new IOException("could not read index block with size: " + indexBlockSize);
}
}
// put the index block in the map
this.map.put(indexCacheEntryKey, indexBlock);
}
// calculate the address of the index entry inside the index block
long indexEntryInBlock = blockNumber % INDEX_ENTRIES_PER_BLOCK;
int addressInIndexBlock = (int) (indexEntryInBlock * SubFileParameter.BYTES_PER_INDEX_ENTRY);
// return the real index entry
return Deserializer.getFiveBytesLong(indexBlock, addressInIndexBlock);
} | [
"long",
"getIndexEntry",
"(",
"SubFileParameter",
"subFileParameter",
",",
"long",
"blockNumber",
")",
"throws",
"IOException",
"{",
"// check if the block number is out of bounds",
"if",
"(",
"blockNumber",
">=",
"subFileParameter",
".",
"numberOfBlocks",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"invalid block number: \"",
"+",
"blockNumber",
")",
";",
"}",
"// calculate the index block number",
"long",
"indexBlockNumber",
"=",
"blockNumber",
"/",
"INDEX_ENTRIES_PER_BLOCK",
";",
"// create the cache entry key for this request",
"IndexCacheEntryKey",
"indexCacheEntryKey",
"=",
"new",
"IndexCacheEntryKey",
"(",
"subFileParameter",
",",
"indexBlockNumber",
")",
";",
"// check for cached index block",
"byte",
"[",
"]",
"indexBlock",
"=",
"this",
".",
"map",
".",
"get",
"(",
"indexCacheEntryKey",
")",
";",
"if",
"(",
"indexBlock",
"==",
"null",
")",
"{",
"// cache miss, seek to the correct index block in the file and read it",
"long",
"indexBlockPosition",
"=",
"subFileParameter",
".",
"indexStartAddress",
"+",
"indexBlockNumber",
"*",
"SIZE_OF_INDEX_BLOCK",
";",
"int",
"remainingIndexSize",
"=",
"(",
"int",
")",
"(",
"subFileParameter",
".",
"indexEndAddress",
"-",
"indexBlockPosition",
")",
";",
"int",
"indexBlockSize",
"=",
"Math",
".",
"min",
"(",
"SIZE_OF_INDEX_BLOCK",
",",
"remainingIndexSize",
")",
";",
"indexBlock",
"=",
"new",
"byte",
"[",
"indexBlockSize",
"]",
";",
"ByteBuffer",
"indexBlockWrapper",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"indexBlock",
",",
"0",
",",
"indexBlockSize",
")",
";",
"synchronized",
"(",
"this",
".",
"fileChannel",
")",
"{",
"this",
".",
"fileChannel",
".",
"position",
"(",
"indexBlockPosition",
")",
";",
"if",
"(",
"this",
".",
"fileChannel",
".",
"read",
"(",
"indexBlockWrapper",
")",
"!=",
"indexBlockSize",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"could not read index block with size: \"",
"+",
"indexBlockSize",
")",
";",
"}",
"}",
"// put the index block in the map",
"this",
".",
"map",
".",
"put",
"(",
"indexCacheEntryKey",
",",
"indexBlock",
")",
";",
"}",
"// calculate the address of the index entry inside the index block",
"long",
"indexEntryInBlock",
"=",
"blockNumber",
"%",
"INDEX_ENTRIES_PER_BLOCK",
";",
"int",
"addressInIndexBlock",
"=",
"(",
"int",
")",
"(",
"indexEntryInBlock",
"*",
"SubFileParameter",
".",
"BYTES_PER_INDEX_ENTRY",
")",
";",
"// return the real index entry",
"return",
"Deserializer",
".",
"getFiveBytesLong",
"(",
"indexBlock",
",",
"addressInIndexBlock",
")",
";",
"}"
] | Returns the index entry of a block in the given map file. If the required index entry is not cached, it will be
read from the map file index and put in the cache.
@param subFileParameter the parameters of the map file for which the index entry is needed.
@param blockNumber the number of the block in the map file.
@return the index entry.
@throws IOException if an I/O error occurs during reading. | [
"Returns",
"the",
"index",
"entry",
"of",
"a",
"block",
"in",
"the",
"given",
"map",
"file",
".",
"If",
"the",
"required",
"index",
"entry",
"is",
"not",
"cached",
"it",
"will",
"be",
"read",
"from",
"the",
"map",
"file",
"index",
"and",
"put",
"in",
"the",
"cache",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/IndexCache.java#L71-L111 |
28,325 | mapsforge/mapsforge | mapsforge-poi/src/main/java/org/mapsforge/poi/storage/PoiCategoryRangeQueryGenerator.java | PoiCategoryRangeQueryGenerator.getSQLWhereClauseString | private static String getSQLWhereClauseString(PoiCategoryFilter filter, int version) {
Collection<PoiCategory> superCategories = filter.getAcceptedSuperCategories();
if (superCategories.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append(" AND (");
// for each super category
for (Iterator<PoiCategory> superCatIter = superCategories.iterator(); superCatIter.hasNext(); ) {
PoiCategory superCat = superCatIter.next();
// All child categories of the super category, including their children
Collection<PoiCategory> categories = superCat.deepChildren();
// Don't forget the super category itself in the search!
categories.add(superCat);
if (version < 2) {
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN_V1);
} else {
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN);
}
// for each category
for (Iterator<PoiCategory> catIter = categories.iterator(); catIter.hasNext(); ) {
PoiCategory cat = catIter.next();
sb.append(cat.getID());
if (catIter.hasNext()) {
sb.append(", ");
}
}
sb.append(")");
// append OR if it is not the last
if (superCatIter.hasNext()) {
sb.append(" OR ");
}
}
sb.append(")");
return sb.toString();
} | java | private static String getSQLWhereClauseString(PoiCategoryFilter filter, int version) {
Collection<PoiCategory> superCategories = filter.getAcceptedSuperCategories();
if (superCategories.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append(" AND (");
// for each super category
for (Iterator<PoiCategory> superCatIter = superCategories.iterator(); superCatIter.hasNext(); ) {
PoiCategory superCat = superCatIter.next();
// All child categories of the super category, including their children
Collection<PoiCategory> categories = superCat.deepChildren();
// Don't forget the super category itself in the search!
categories.add(superCat);
if (version < 2) {
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN_V1);
} else {
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN);
}
// for each category
for (Iterator<PoiCategory> catIter = categories.iterator(); catIter.hasNext(); ) {
PoiCategory cat = catIter.next();
sb.append(cat.getID());
if (catIter.hasNext()) {
sb.append(", ");
}
}
sb.append(")");
// append OR if it is not the last
if (superCatIter.hasNext()) {
sb.append(" OR ");
}
}
sb.append(")");
return sb.toString();
} | [
"private",
"static",
"String",
"getSQLWhereClauseString",
"(",
"PoiCategoryFilter",
"filter",
",",
"int",
"version",
")",
"{",
"Collection",
"<",
"PoiCategory",
">",
"superCategories",
"=",
"filter",
".",
"getAcceptedSuperCategories",
"(",
")",
";",
"if",
"(",
"superCategories",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\" AND (\"",
")",
";",
"// for each super category",
"for",
"(",
"Iterator",
"<",
"PoiCategory",
">",
"superCatIter",
"=",
"superCategories",
".",
"iterator",
"(",
")",
";",
"superCatIter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"PoiCategory",
"superCat",
"=",
"superCatIter",
".",
"next",
"(",
")",
";",
"// All child categories of the super category, including their children",
"Collection",
"<",
"PoiCategory",
">",
"categories",
"=",
"superCat",
".",
"deepChildren",
"(",
")",
";",
"// Don't forget the super category itself in the search!",
"categories",
".",
"add",
"(",
"superCat",
")",
";",
"if",
"(",
"version",
"<",
"2",
")",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN_V1",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN",
")",
";",
"}",
"// for each category",
"for",
"(",
"Iterator",
"<",
"PoiCategory",
">",
"catIter",
"=",
"categories",
".",
"iterator",
"(",
")",
";",
"catIter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"PoiCategory",
"cat",
"=",
"catIter",
".",
"next",
"(",
")",
";",
"sb",
".",
"append",
"(",
"cat",
".",
"getID",
"(",
")",
")",
";",
"if",
"(",
"catIter",
".",
"hasNext",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"// append OR if it is not the last",
"if",
"(",
"superCatIter",
".",
"hasNext",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\" OR \"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Gets the WHERE clause for the SQL query that looks up POI entries.
@param filter The filter object for determining all wanted categories.
@param version POI specification version.
@return The WHERE clause. | [
"Gets",
"the",
"WHERE",
"clause",
"for",
"the",
"SQL",
"query",
"that",
"looks",
"up",
"POI",
"entries",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-poi/src/main/java/org/mapsforge/poi/storage/PoiCategoryRangeQueryGenerator.java#L66-L107 |
28,326 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java | PolyLabel.getCentroidCell | private static Cell getCentroidCell(Polygon polygon) {
double area = 0.0;
double x = 0.0;
double y = 0.0;
LineString exterior = polygon.getExteriorRing();
for (int i = 0, n = exterior.getNumPoints() - 1, j = n - 1; i < n; j = i, i++) {
Coordinate a = exterior.getCoordinateN(i);
Coordinate b = exterior.getCoordinateN(j);
double f = a.x * b.y - b.x * a.y;
x += (a.x + b.x) * f;
y += (a.y + b.y) * f;
area += f * 3.0;
}
return new Cell(x / area, y / area, 0.0, polygon);
} | java | private static Cell getCentroidCell(Polygon polygon) {
double area = 0.0;
double x = 0.0;
double y = 0.0;
LineString exterior = polygon.getExteriorRing();
for (int i = 0, n = exterior.getNumPoints() - 1, j = n - 1; i < n; j = i, i++) {
Coordinate a = exterior.getCoordinateN(i);
Coordinate b = exterior.getCoordinateN(j);
double f = a.x * b.y - b.x * a.y;
x += (a.x + b.x) * f;
y += (a.y + b.y) * f;
area += f * 3.0;
}
return new Cell(x / area, y / area, 0.0, polygon);
} | [
"private",
"static",
"Cell",
"getCentroidCell",
"(",
"Polygon",
"polygon",
")",
"{",
"double",
"area",
"=",
"0.0",
";",
"double",
"x",
"=",
"0.0",
";",
"double",
"y",
"=",
"0.0",
";",
"LineString",
"exterior",
"=",
"polygon",
".",
"getExteriorRing",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"exterior",
".",
"getNumPoints",
"(",
")",
"-",
"1",
",",
"j",
"=",
"n",
"-",
"1",
";",
"i",
"<",
"n",
";",
"j",
"=",
"i",
",",
"i",
"++",
")",
"{",
"Coordinate",
"a",
"=",
"exterior",
".",
"getCoordinateN",
"(",
"i",
")",
";",
"Coordinate",
"b",
"=",
"exterior",
".",
"getCoordinateN",
"(",
"j",
")",
";",
"double",
"f",
"=",
"a",
".",
"x",
"*",
"b",
".",
"y",
"-",
"b",
".",
"x",
"*",
"a",
".",
"y",
";",
"x",
"+=",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"*",
"f",
";",
"y",
"+=",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"*",
"f",
";",
"area",
"+=",
"f",
"*",
"3.0",
";",
"}",
"return",
"new",
"Cell",
"(",
"x",
"/",
"area",
",",
"y",
"/",
"area",
",",
"0.0",
",",
"polygon",
")",
";",
"}"
] | Get polygon centroid | [
"Get",
"polygon",
"centroid"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java#L191-L207 |
28,327 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java | PolyLabel.getSegDistSq | private static double getSegDistSq(double px, double py, Coordinate a, Coordinate b) {
double x = a.x;
double y = a.y;
double dx = b.x - x;
double dy = b.y - y;
if (dx != 0f || dy != 0f) {
double t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
if (t > 1) {
x = b.x;
y = b.y;
} else if (t > 0) {
x += dx * t;
y += dy * t;
}
}
dx = px - x;
dy = py - y;
return dx * dx + dy * dy;
} | java | private static double getSegDistSq(double px, double py, Coordinate a, Coordinate b) {
double x = a.x;
double y = a.y;
double dx = b.x - x;
double dy = b.y - y;
if (dx != 0f || dy != 0f) {
double t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
if (t > 1) {
x = b.x;
y = b.y;
} else if (t > 0) {
x += dx * t;
y += dy * t;
}
}
dx = px - x;
dy = py - y;
return dx * dx + dy * dy;
} | [
"private",
"static",
"double",
"getSegDistSq",
"(",
"double",
"px",
",",
"double",
"py",
",",
"Coordinate",
"a",
",",
"Coordinate",
"b",
")",
"{",
"double",
"x",
"=",
"a",
".",
"x",
";",
"double",
"y",
"=",
"a",
".",
"y",
";",
"double",
"dx",
"=",
"b",
".",
"x",
"-",
"x",
";",
"double",
"dy",
"=",
"b",
".",
"y",
"-",
"y",
";",
"if",
"(",
"dx",
"!=",
"0f",
"||",
"dy",
"!=",
"0f",
")",
"{",
"double",
"t",
"=",
"(",
"(",
"px",
"-",
"x",
")",
"*",
"dx",
"+",
"(",
"py",
"-",
"y",
")",
"*",
"dy",
")",
"/",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
")",
";",
"if",
"(",
"t",
">",
"1",
")",
"{",
"x",
"=",
"b",
".",
"x",
";",
"y",
"=",
"b",
".",
"y",
";",
"}",
"else",
"if",
"(",
"t",
">",
"0",
")",
"{",
"x",
"+=",
"dx",
"*",
"t",
";",
"y",
"+=",
"dy",
"*",
"t",
";",
"}",
"}",
"dx",
"=",
"px",
"-",
"x",
";",
"dy",
"=",
"py",
"-",
"y",
";",
"return",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
";",
"}"
] | Get squared distance from a point to a segment | [
"Get",
"squared",
"distance",
"from",
"a",
"point",
"to",
"a",
"segment"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java#L210-L232 |
28,328 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java | PolyLabel.latitudeToY | private static double latitudeToY(double latitude) {
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
return 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
} | java | private static double latitudeToY(double latitude) {
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
return 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
} | [
"private",
"static",
"double",
"latitudeToY",
"(",
"double",
"latitude",
")",
"{",
"double",
"sinLatitude",
"=",
"Math",
".",
"sin",
"(",
"latitude",
"*",
"(",
"Math",
".",
"PI",
"/",
"180",
")",
")",
";",
"return",
"0.5",
"-",
"Math",
".",
"log",
"(",
"(",
"1",
"+",
"sinLatitude",
")",
"/",
"(",
"1",
"-",
"sinLatitude",
")",
")",
"/",
"(",
"4",
"*",
"Math",
".",
"PI",
")",
";",
"}"
] | Re-projection functions | [
"Re",
"-",
"projection",
"functions"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/PolyLabel.java#L236-L239 |
28,329 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TileCoordinate.java | TileCoordinate.translateToZoomLevel | public List<TileCoordinate> translateToZoomLevel(byte zoomlevelNew) {
List<TileCoordinate> tiles = null;
int zoomlevelDistance = zoomlevelNew - this.zoomlevel;
int factor = (int) Math.pow(2, Math.abs(zoomlevelDistance));
if (zoomlevelDistance > 0) {
tiles = new ArrayList<>((int) Math.pow(4, Math.abs(zoomlevelDistance)));
int tileUpperLeftX = this.x * factor;
int tileUpperLeftY = this.y * factor;
for (int i = 0; i < factor; i++) {
for (int j = 0; j < factor; j++) {
tiles.add(new TileCoordinate(tileUpperLeftX + j, tileUpperLeftY + i, zoomlevelNew));
}
}
} else {
tiles = new ArrayList<>(1);
tiles.add(new TileCoordinate(this.x / factor, this.y / factor, zoomlevelNew));
}
return tiles;
} | java | public List<TileCoordinate> translateToZoomLevel(byte zoomlevelNew) {
List<TileCoordinate> tiles = null;
int zoomlevelDistance = zoomlevelNew - this.zoomlevel;
int factor = (int) Math.pow(2, Math.abs(zoomlevelDistance));
if (zoomlevelDistance > 0) {
tiles = new ArrayList<>((int) Math.pow(4, Math.abs(zoomlevelDistance)));
int tileUpperLeftX = this.x * factor;
int tileUpperLeftY = this.y * factor;
for (int i = 0; i < factor; i++) {
for (int j = 0; j < factor; j++) {
tiles.add(new TileCoordinate(tileUpperLeftX + j, tileUpperLeftY + i, zoomlevelNew));
}
}
} else {
tiles = new ArrayList<>(1);
tiles.add(new TileCoordinate(this.x / factor, this.y / factor, zoomlevelNew));
}
return tiles;
} | [
"public",
"List",
"<",
"TileCoordinate",
">",
"translateToZoomLevel",
"(",
"byte",
"zoomlevelNew",
")",
"{",
"List",
"<",
"TileCoordinate",
">",
"tiles",
"=",
"null",
";",
"int",
"zoomlevelDistance",
"=",
"zoomlevelNew",
"-",
"this",
".",
"zoomlevel",
";",
"int",
"factor",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"2",
",",
"Math",
".",
"abs",
"(",
"zoomlevelDistance",
")",
")",
";",
"if",
"(",
"zoomlevelDistance",
">",
"0",
")",
"{",
"tiles",
"=",
"new",
"ArrayList",
"<>",
"(",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"4",
",",
"Math",
".",
"abs",
"(",
"zoomlevelDistance",
")",
")",
")",
";",
"int",
"tileUpperLeftX",
"=",
"this",
".",
"x",
"*",
"factor",
";",
"int",
"tileUpperLeftY",
"=",
"this",
".",
"y",
"*",
"factor",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"factor",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"factor",
";",
"j",
"++",
")",
"{",
"tiles",
".",
"add",
"(",
"new",
"TileCoordinate",
"(",
"tileUpperLeftX",
"+",
"j",
",",
"tileUpperLeftY",
"+",
"i",
",",
"zoomlevelNew",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"tiles",
"=",
"new",
"ArrayList",
"<>",
"(",
"1",
")",
";",
"tiles",
".",
"add",
"(",
"new",
"TileCoordinate",
"(",
"this",
".",
"x",
"/",
"factor",
",",
"this",
".",
"y",
"/",
"factor",
",",
"zoomlevelNew",
")",
")",
";",
"}",
"return",
"tiles",
";",
"}"
] | Computes which tile on a lower zoom level covers this given tile or which tiles on a higher zoom level together
cover this tile.
@param zoomlevelNew the zoom level
@return a list of tiles (represented by tile coordinates) which cover this tile | [
"Computes",
"which",
"tile",
"on",
"a",
"lower",
"zoom",
"level",
"covers",
"this",
"given",
"tile",
"or",
"which",
"tiles",
"on",
"a",
"higher",
"zoom",
"level",
"together",
"cover",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TileCoordinate.java#L109-L128 |
28,330 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/JTSUtils.java | JTSUtils.toJtsGeometry | public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) {
if (way == null) {
LOGGER.warning("way is null");
return null;
}
if (way.isForcePolygonLine()) {
// may build a single line string if inner ways are empty
return buildMultiLineString(way, innerWays);
}
if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) {
// Have to be careful here about polygons and lines again, the problem with
// polygons is that a certain direction is forced, so we do not want to reverse
// closed lines that are not meant to be polygons
// may contain holes if inner ways are not empty
Polygon polygon = buildPolygon(way, innerWays);
if (polygon.isValid()) {
return polygon;
}
return repairInvalidPolygon(polygon);
}
// not a closed line
return buildLineString(way);
} | java | public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) {
if (way == null) {
LOGGER.warning("way is null");
return null;
}
if (way.isForcePolygonLine()) {
// may build a single line string if inner ways are empty
return buildMultiLineString(way, innerWays);
}
if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) {
// Have to be careful here about polygons and lines again, the problem with
// polygons is that a certain direction is forced, so we do not want to reverse
// closed lines that are not meant to be polygons
// may contain holes if inner ways are not empty
Polygon polygon = buildPolygon(way, innerWays);
if (polygon.isValid()) {
return polygon;
}
return repairInvalidPolygon(polygon);
}
// not a closed line
return buildLineString(way);
} | [
"public",
"static",
"Geometry",
"toJtsGeometry",
"(",
"TDWay",
"way",
",",
"List",
"<",
"TDWay",
">",
"innerWays",
")",
"{",
"if",
"(",
"way",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"way is null\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"way",
".",
"isForcePolygonLine",
"(",
")",
")",
"{",
"// may build a single line string if inner ways are empty",
"return",
"buildMultiLineString",
"(",
"way",
",",
"innerWays",
")",
";",
"}",
"if",
"(",
"way",
".",
"getShape",
"(",
")",
"!=",
"TDWay",
".",
"LINE",
"||",
"innerWays",
"!=",
"null",
"&&",
"innerWays",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"// Have to be careful here about polygons and lines again, the problem with",
"// polygons is that a certain direction is forced, so we do not want to reverse",
"// closed lines that are not meant to be polygons",
"// may contain holes if inner ways are not empty",
"Polygon",
"polygon",
"=",
"buildPolygon",
"(",
"way",
",",
"innerWays",
")",
";",
"if",
"(",
"polygon",
".",
"isValid",
"(",
")",
")",
"{",
"return",
"polygon",
";",
"}",
"return",
"repairInvalidPolygon",
"(",
"polygon",
")",
";",
"}",
"// not a closed line",
"return",
"buildLineString",
"(",
"way",
")",
";",
"}"
] | Converts a way with potential inner ways to a JTS geometry.
@param way the way
@param innerWays the inner ways or null
@return the JTS geometry | [
"Converts",
"a",
"way",
"with",
"potential",
"inner",
"ways",
"to",
"a",
"JTS",
"geometry",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/JTSUtils.java#L74-L98 |
28,331 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LineString.java | LineString.extractPart | public LineString extractPart(double startDistance, double endDistance) {
LineString result = new LineString();
for (int i = 0; i < this.segments.size(); startDistance -= this.segments.get(i).length(), endDistance -= this.segments.get(i).length(), i++) {
LineSegment segment = this.segments.get(i);
// Skip first segments that we don't need
double length = segment.length();
if (length < startDistance) {
continue;
}
Point startPoint = null, endPoint = null;
if (startDistance >= 0) {
// This will be our starting point
startPoint = segment.pointAlongLineSegment(startDistance);
}
if (endDistance < length) {
// this will be our ending point
endPoint = segment.pointAlongLineSegment(endDistance);
}
if (startPoint != null && endPoint == null) {
// This ist the starting segment, end will come in a later segment
result.segments.add(new LineSegment(startPoint, segment.end));
} else if (startPoint == null && endPoint == null) {
// Center segment between start and end segment, add completely
result.segments.add(segment);
} else if (startPoint == null && endPoint != null) {
// End segment, start was in earlier segment
result.segments.add(new LineSegment(segment.start, endPoint));
} else if (startPoint != null && endPoint != null) {
// Start and end on same segment
result.segments.add(new LineSegment(startPoint, endPoint));
}
if (endPoint != null)
break;
}
return result;
} | java | public LineString extractPart(double startDistance, double endDistance) {
LineString result = new LineString();
for (int i = 0; i < this.segments.size(); startDistance -= this.segments.get(i).length(), endDistance -= this.segments.get(i).length(), i++) {
LineSegment segment = this.segments.get(i);
// Skip first segments that we don't need
double length = segment.length();
if (length < startDistance) {
continue;
}
Point startPoint = null, endPoint = null;
if (startDistance >= 0) {
// This will be our starting point
startPoint = segment.pointAlongLineSegment(startDistance);
}
if (endDistance < length) {
// this will be our ending point
endPoint = segment.pointAlongLineSegment(endDistance);
}
if (startPoint != null && endPoint == null) {
// This ist the starting segment, end will come in a later segment
result.segments.add(new LineSegment(startPoint, segment.end));
} else if (startPoint == null && endPoint == null) {
// Center segment between start and end segment, add completely
result.segments.add(segment);
} else if (startPoint == null && endPoint != null) {
// End segment, start was in earlier segment
result.segments.add(new LineSegment(segment.start, endPoint));
} else if (startPoint != null && endPoint != null) {
// Start and end on same segment
result.segments.add(new LineSegment(startPoint, endPoint));
}
if (endPoint != null)
break;
}
return result;
} | [
"public",
"LineString",
"extractPart",
"(",
"double",
"startDistance",
",",
"double",
"endDistance",
")",
"{",
"LineString",
"result",
"=",
"new",
"LineString",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"segments",
".",
"size",
"(",
")",
";",
"startDistance",
"-=",
"this",
".",
"segments",
".",
"get",
"(",
"i",
")",
".",
"length",
"(",
")",
",",
"endDistance",
"-=",
"this",
".",
"segments",
".",
"get",
"(",
"i",
")",
".",
"length",
"(",
")",
",",
"i",
"++",
")",
"{",
"LineSegment",
"segment",
"=",
"this",
".",
"segments",
".",
"get",
"(",
"i",
")",
";",
"// Skip first segments that we don't need",
"double",
"length",
"=",
"segment",
".",
"length",
"(",
")",
";",
"if",
"(",
"length",
"<",
"startDistance",
")",
"{",
"continue",
";",
"}",
"Point",
"startPoint",
"=",
"null",
",",
"endPoint",
"=",
"null",
";",
"if",
"(",
"startDistance",
">=",
"0",
")",
"{",
"// This will be our starting point",
"startPoint",
"=",
"segment",
".",
"pointAlongLineSegment",
"(",
"startDistance",
")",
";",
"}",
"if",
"(",
"endDistance",
"<",
"length",
")",
"{",
"// this will be our ending point",
"endPoint",
"=",
"segment",
".",
"pointAlongLineSegment",
"(",
"endDistance",
")",
";",
"}",
"if",
"(",
"startPoint",
"!=",
"null",
"&&",
"endPoint",
"==",
"null",
")",
"{",
"// This ist the starting segment, end will come in a later segment",
"result",
".",
"segments",
".",
"add",
"(",
"new",
"LineSegment",
"(",
"startPoint",
",",
"segment",
".",
"end",
")",
")",
";",
"}",
"else",
"if",
"(",
"startPoint",
"==",
"null",
"&&",
"endPoint",
"==",
"null",
")",
"{",
"// Center segment between start and end segment, add completely",
"result",
".",
"segments",
".",
"add",
"(",
"segment",
")",
";",
"}",
"else",
"if",
"(",
"startPoint",
"==",
"null",
"&&",
"endPoint",
"!=",
"null",
")",
"{",
"// End segment, start was in earlier segment",
"result",
".",
"segments",
".",
"add",
"(",
"new",
"LineSegment",
"(",
"segment",
".",
"start",
",",
"endPoint",
")",
")",
";",
"}",
"else",
"if",
"(",
"startPoint",
"!=",
"null",
"&&",
"endPoint",
"!=",
"null",
")",
"{",
"// Start and end on same segment",
"result",
".",
"segments",
".",
"add",
"(",
"new",
"LineSegment",
"(",
"startPoint",
",",
"endPoint",
")",
")",
";",
"}",
"if",
"(",
"endPoint",
"!=",
"null",
")",
"break",
";",
"}",
"return",
"result",
";",
"}"
] | Creates a new LineString that consists of only the part between startDistance and endDistance. | [
"Creates",
"a",
"new",
"LineString",
"that",
"consists",
"of",
"only",
"the",
"part",
"between",
"startDistance",
"and",
"endDistance",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LineString.java#L48-L89 |
28,332 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java | SQLiteDebug.shouldLogSlowQuery | public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) {
int slowQueryMillis = Integer.parseInt(
System.getProperty("db.log.slow_query_threshold", "10000")
);
return slowQueryMillis >= 0 && elapsedTimeMillis >= slowQueryMillis;
} | java | public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) {
int slowQueryMillis = Integer.parseInt(
System.getProperty("db.log.slow_query_threshold", "10000")
);
return slowQueryMillis >= 0 && elapsedTimeMillis >= slowQueryMillis;
} | [
"public",
"static",
"final",
"boolean",
"shouldLogSlowQuery",
"(",
"long",
"elapsedTimeMillis",
")",
"{",
"int",
"slowQueryMillis",
"=",
"Integer",
".",
"parseInt",
"(",
"System",
".",
"getProperty",
"(",
"\"db.log.slow_query_threshold\"",
",",
"\"10000\"",
")",
")",
";",
"return",
"slowQueryMillis",
">=",
"0",
"&&",
"elapsedTimeMillis",
">=",
"slowQueryMillis",
";",
"}"
] | Determines whether a query should be logged.
Reads the "db.log.slow_query_threshold" system property, which can be changed
by the user at any time. If the value is zero, then all queries will
be considered slow. If the value does not exist or is negative, then no queries will
be considered slow.
This value can be changed dynamically while the system is running.
For example, "adb shell setprop db.log.slow_query_threshold 200" will
log all queries that take 200ms or longer to run.
@hide | [
"Determines",
"whether",
"a",
"query",
"should",
"be",
"logged",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java#L85-L90 |
28,333 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java | SQLiteDebug.getDatabaseInfo | public static PagerStats getDatabaseInfo() {
PagerStats stats = new PagerStats();
nativeGetPagerStats(stats);
stats.dbStats = SQLiteDatabase.getDbStats();
return stats;
} | java | public static PagerStats getDatabaseInfo() {
PagerStats stats = new PagerStats();
nativeGetPagerStats(stats);
stats.dbStats = SQLiteDatabase.getDbStats();
return stats;
} | [
"public",
"static",
"PagerStats",
"getDatabaseInfo",
"(",
")",
"{",
"PagerStats",
"stats",
"=",
"new",
"PagerStats",
"(",
")",
";",
"nativeGetPagerStats",
"(",
"stats",
")",
";",
"stats",
".",
"dbStats",
"=",
"SQLiteDatabase",
".",
"getDbStats",
"(",
")",
";",
"return",
"stats",
";",
"}"
] | return all pager and database stats for the current process.
@return {@link PagerStats} | [
"return",
"all",
"pager",
"and",
"database",
"stats",
"for",
"the",
"current",
"process",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java#L156-L161 |
28,334 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java | SQLiteDebug.dump | public static void dump(Printer printer, String[] args) {
boolean verbose = false;
for (String arg : args) {
if (arg.equals("-v")) {
verbose = true;
}
}
SQLiteDatabase.dumpAll(printer, verbose);
} | java | public static void dump(Printer printer, String[] args) {
boolean verbose = false;
for (String arg : args) {
if (arg.equals("-v")) {
verbose = true;
}
}
SQLiteDatabase.dumpAll(printer, verbose);
} | [
"public",
"static",
"void",
"dump",
"(",
"Printer",
"printer",
",",
"String",
"[",
"]",
"args",
")",
"{",
"boolean",
"verbose",
"=",
"false",
";",
"for",
"(",
"String",
"arg",
":",
"args",
")",
"{",
"if",
"(",
"arg",
".",
"equals",
"(",
"\"-v\"",
")",
")",
"{",
"verbose",
"=",
"true",
";",
"}",
"}",
"SQLiteDatabase",
".",
"dumpAll",
"(",
"printer",
",",
"verbose",
")",
";",
"}"
] | Dumps detailed information about all databases used by the process.
@param printer The printer for dumping database state.
@param args Command-line arguments supplied to dumpsys dbinfo | [
"Dumps",
"detailed",
"information",
"about",
"all",
"databases",
"used",
"by",
"the",
"process",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java#L168-L177 |
28,335 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.distance | public static double distance(LatLong latLong1, LatLong latLong2) {
return Math.hypot(latLong1.longitude - latLong2.longitude, latLong1.latitude - latLong2.latitude);
} | java | public static double distance(LatLong latLong1, LatLong latLong2) {
return Math.hypot(latLong1.longitude - latLong2.longitude, latLong1.latitude - latLong2.latitude);
} | [
"public",
"static",
"double",
"distance",
"(",
"LatLong",
"latLong1",
",",
"LatLong",
"latLong2",
")",
"{",
"return",
"Math",
".",
"hypot",
"(",
"latLong1",
".",
"longitude",
"-",
"latLong2",
".",
"longitude",
",",
"latLong1",
".",
"latitude",
"-",
"latLong2",
".",
"latitude",
")",
";",
"}"
] | Calculate the Euclidean distance between two LatLongs in degrees using the Pythagorean
theorem.
@param latLong1 first LatLong
@param latLong2 second LatLong
@return distance in degrees as a double | [
"Calculate",
"the",
"Euclidean",
"distance",
"between",
"two",
"LatLongs",
"in",
"degrees",
"using",
"the",
"Pythagorean",
"theorem",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L158-L160 |
28,336 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.fromString | public static LatLong fromString(String latLongString) {
double[] coordinates = parseCoordinateString(latLongString, 2);
return new LatLong(coordinates[0], coordinates[1]);
} | java | public static LatLong fromString(String latLongString) {
double[] coordinates = parseCoordinateString(latLongString, 2);
return new LatLong(coordinates[0], coordinates[1]);
} | [
"public",
"static",
"LatLong",
"fromString",
"(",
"String",
"latLongString",
")",
"{",
"double",
"[",
"]",
"coordinates",
"=",
"parseCoordinateString",
"(",
"latLongString",
",",
"2",
")",
";",
"return",
"new",
"LatLong",
"(",
"coordinates",
"[",
"0",
"]",
",",
"coordinates",
"[",
"1",
"]",
")",
";",
"}"
] | Creates a new LatLong from a comma-separated string of coordinates in the order latitude, longitude. All
coordinate values must be in degrees.
@param latLongString the string that describes the LatLong.
@return a new LatLong with the given coordinates.
@throws IllegalArgumentException if the string cannot be parsed or describes an invalid LatLong. | [
"Creates",
"a",
"new",
"LatLong",
"from",
"a",
"comma",
"-",
"separated",
"string",
"of",
"coordinates",
"in",
"the",
"order",
"latitude",
"longitude",
".",
"All",
"coordinate",
"values",
"must",
"be",
"in",
"degrees",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L180-L183 |
28,337 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.longitudeDistance | public static double longitudeDistance(int meters, double latitude) {
return (meters * 360) / (2 * Math.PI * EQUATORIAL_RADIUS * Math.cos(Math.toRadians(latitude)));
} | java | public static double longitudeDistance(int meters, double latitude) {
return (meters * 360) / (2 * Math.PI * EQUATORIAL_RADIUS * Math.cos(Math.toRadians(latitude)));
} | [
"public",
"static",
"double",
"longitudeDistance",
"(",
"int",
"meters",
",",
"double",
"latitude",
")",
"{",
"return",
"(",
"meters",
"*",
"360",
")",
"/",
"(",
"2",
"*",
"Math",
".",
"PI",
"*",
"EQUATORIAL_RADIUS",
"*",
"Math",
".",
"cos",
"(",
"Math",
".",
"toRadians",
"(",
"latitude",
")",
")",
")",
";",
"}"
] | Calculates the amount of degrees of longitude for a given distance in meters.
@param meters distance in meters
@param latitude the latitude at which the calculation should be performed
@return longitude degrees | [
"Calculates",
"the",
"amount",
"of",
"degrees",
"of",
"longitude",
"for",
"a",
"given",
"distance",
"in",
"meters",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L211-L213 |
28,338 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.parseCoordinateString | public static double[] parseCoordinateString(String coordinatesString, int numberOfCoordinates) {
StringTokenizer stringTokenizer = new StringTokenizer(coordinatesString, DELIMITER, true);
boolean isDelimiter = true;
List<String> tokens = new ArrayList<>(numberOfCoordinates);
while (stringTokenizer.hasMoreTokens()) {
String token = stringTokenizer.nextToken();
isDelimiter = !isDelimiter;
if (isDelimiter) {
continue;
}
tokens.add(token);
}
if (isDelimiter) {
throw new IllegalArgumentException("invalid coordinate delimiter: " + coordinatesString);
} else if (tokens.size() != numberOfCoordinates) {
throw new IllegalArgumentException("invalid number of coordinate values: " + coordinatesString);
}
double[] coordinates = new double[numberOfCoordinates];
for (int i = 0; i < numberOfCoordinates; ++i) {
coordinates[i] = Double.parseDouble(tokens.get(i));
}
return coordinates;
} | java | public static double[] parseCoordinateString(String coordinatesString, int numberOfCoordinates) {
StringTokenizer stringTokenizer = new StringTokenizer(coordinatesString, DELIMITER, true);
boolean isDelimiter = true;
List<String> tokens = new ArrayList<>(numberOfCoordinates);
while (stringTokenizer.hasMoreTokens()) {
String token = stringTokenizer.nextToken();
isDelimiter = !isDelimiter;
if (isDelimiter) {
continue;
}
tokens.add(token);
}
if (isDelimiter) {
throw new IllegalArgumentException("invalid coordinate delimiter: " + coordinatesString);
} else if (tokens.size() != numberOfCoordinates) {
throw new IllegalArgumentException("invalid number of coordinate values: " + coordinatesString);
}
double[] coordinates = new double[numberOfCoordinates];
for (int i = 0; i < numberOfCoordinates; ++i) {
coordinates[i] = Double.parseDouble(tokens.get(i));
}
return coordinates;
} | [
"public",
"static",
"double",
"[",
"]",
"parseCoordinateString",
"(",
"String",
"coordinatesString",
",",
"int",
"numberOfCoordinates",
")",
"{",
"StringTokenizer",
"stringTokenizer",
"=",
"new",
"StringTokenizer",
"(",
"coordinatesString",
",",
"DELIMITER",
",",
"true",
")",
";",
"boolean",
"isDelimiter",
"=",
"true",
";",
"List",
"<",
"String",
">",
"tokens",
"=",
"new",
"ArrayList",
"<>",
"(",
"numberOfCoordinates",
")",
";",
"while",
"(",
"stringTokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"token",
"=",
"stringTokenizer",
".",
"nextToken",
"(",
")",
";",
"isDelimiter",
"=",
"!",
"isDelimiter",
";",
"if",
"(",
"isDelimiter",
")",
"{",
"continue",
";",
"}",
"tokens",
".",
"add",
"(",
"token",
")",
";",
"}",
"if",
"(",
"isDelimiter",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid coordinate delimiter: \"",
"+",
"coordinatesString",
")",
";",
"}",
"else",
"if",
"(",
"tokens",
".",
"size",
"(",
")",
"!=",
"numberOfCoordinates",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid number of coordinate values: \"",
"+",
"coordinatesString",
")",
";",
"}",
"double",
"[",
"]",
"coordinates",
"=",
"new",
"double",
"[",
"numberOfCoordinates",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfCoordinates",
";",
"++",
"i",
")",
"{",
"coordinates",
"[",
"i",
"]",
"=",
"Double",
".",
"parseDouble",
"(",
"tokens",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"return",
"coordinates",
";",
"}"
] | Parses a given number of comma-separated coordinate values from the supplied string.
@param coordinatesString a comma-separated string of coordinate values.
@param numberOfCoordinates the expected number of coordinate values in the string.
@return the coordinate values in the order they have been parsed from the string.
@throws IllegalArgumentException if the string is invalid or does not contain the given number of coordinate values. | [
"Parses",
"a",
"given",
"number",
"of",
"comma",
"-",
"separated",
"coordinate",
"values",
"from",
"the",
"supplied",
"string",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L249-L275 |
28,339 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/ClusterMarker.java | ClusterMarker.setMarkerBitmap | private void setMarkerBitmap() {
for (markerType = 0; markerType < cluster.getClusterManager().markerIconBmps.size(); markerType++) {
// Check if the number of items in this cluster is below or equal the limit of the MarkerBitMap
if (cluster.getItems().size() <= cluster.getClusterManager()
.markerIconBmps.get(markerType).getItemMax()) {
return;
}
}
// set the markerType to maximum value ==> reduce markerType by one.
markerType--;
} | java | private void setMarkerBitmap() {
for (markerType = 0; markerType < cluster.getClusterManager().markerIconBmps.size(); markerType++) {
// Check if the number of items in this cluster is below or equal the limit of the MarkerBitMap
if (cluster.getItems().size() <= cluster.getClusterManager()
.markerIconBmps.get(markerType).getItemMax()) {
return;
}
}
// set the markerType to maximum value ==> reduce markerType by one.
markerType--;
} | [
"private",
"void",
"setMarkerBitmap",
"(",
")",
"{",
"for",
"(",
"markerType",
"=",
"0",
";",
"markerType",
"<",
"cluster",
".",
"getClusterManager",
"(",
")",
".",
"markerIconBmps",
".",
"size",
"(",
")",
";",
"markerType",
"++",
")",
"{",
"// Check if the number of items in this cluster is below or equal the limit of the MarkerBitMap",
"if",
"(",
"cluster",
".",
"getItems",
"(",
")",
".",
"size",
"(",
")",
"<=",
"cluster",
".",
"getClusterManager",
"(",
")",
".",
"markerIconBmps",
".",
"get",
"(",
"markerType",
")",
".",
"getItemMax",
"(",
")",
")",
"{",
"return",
";",
"}",
"}",
"// set the markerType to maximum value ==> reduce markerType by one.",
"markerType",
"--",
";",
"}"
] | change icon bitmaps according to the state and content size. | [
"change",
"icon",
"bitmaps",
"according",
"to",
"the",
"state",
"and",
"content",
"size",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/ClusterMarker.java#L68-L78 |
28,340 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteSession.java | SQLiteSession.executeSpecial | private boolean executeSpecial(String sql, Object[] bindArgs, int connectionFlags,
CancellationSignal cancellationSignal) {
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
}
final int type = DatabaseUtils.getSqlStatementType(sql);
switch (type) {
case DatabaseUtils.STATEMENT_BEGIN:
beginTransaction(TRANSACTION_MODE_EXCLUSIVE, null, connectionFlags,
cancellationSignal);
return true;
case DatabaseUtils.STATEMENT_COMMIT:
setTransactionSuccessful();
endTransaction(cancellationSignal);
return true;
case DatabaseUtils.STATEMENT_ABORT:
endTransaction(cancellationSignal);
return true;
}
return false;
} | java | private boolean executeSpecial(String sql, Object[] bindArgs, int connectionFlags,
CancellationSignal cancellationSignal) {
if (cancellationSignal != null) {
cancellationSignal.throwIfCanceled();
}
final int type = DatabaseUtils.getSqlStatementType(sql);
switch (type) {
case DatabaseUtils.STATEMENT_BEGIN:
beginTransaction(TRANSACTION_MODE_EXCLUSIVE, null, connectionFlags,
cancellationSignal);
return true;
case DatabaseUtils.STATEMENT_COMMIT:
setTransactionSuccessful();
endTransaction(cancellationSignal);
return true;
case DatabaseUtils.STATEMENT_ABORT:
endTransaction(cancellationSignal);
return true;
}
return false;
} | [
"private",
"boolean",
"executeSpecial",
"(",
"String",
"sql",
",",
"Object",
"[",
"]",
"bindArgs",
",",
"int",
"connectionFlags",
",",
"CancellationSignal",
"cancellationSignal",
")",
"{",
"if",
"(",
"cancellationSignal",
"!=",
"null",
")",
"{",
"cancellationSignal",
".",
"throwIfCanceled",
"(",
")",
";",
"}",
"final",
"int",
"type",
"=",
"DatabaseUtils",
".",
"getSqlStatementType",
"(",
"sql",
")",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"DatabaseUtils",
".",
"STATEMENT_BEGIN",
":",
"beginTransaction",
"(",
"TRANSACTION_MODE_EXCLUSIVE",
",",
"null",
",",
"connectionFlags",
",",
"cancellationSignal",
")",
";",
"return",
"true",
";",
"case",
"DatabaseUtils",
".",
"STATEMENT_COMMIT",
":",
"setTransactionSuccessful",
"(",
")",
";",
"endTransaction",
"(",
"cancellationSignal",
")",
";",
"return",
"true",
";",
"case",
"DatabaseUtils",
".",
"STATEMENT_ABORT",
":",
"endTransaction",
"(",
"cancellationSignal",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Performs special reinterpretation of certain SQL statements such as "BEGIN",
"COMMIT" and "ROLLBACK" to ensure that transaction state invariants are
maintained.
This function is mainly used to support legacy apps that perform their
own transactions by executing raw SQL rather than calling {@link #beginTransaction}
and the like.
@param sql The SQL statement to execute.
@param bindArgs The arguments to bind, or null if none.
@param connectionFlags The connection flags to use if a connection must be
acquired by this operation. Refer to {@link SQLiteConnectionPool}.
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
@return True if the statement was of a special form that was handled here,
false otherwise.
@throws SQLiteException if an error occurs, such as a syntax error
or invalid number of bind arguments.
@throws OperationCanceledException if the operation was canceled. | [
"Performs",
"special",
"reinterpretation",
"of",
"certain",
"SQL",
"statements",
"such",
"as",
"BEGIN",
"COMMIT",
"and",
"ROLLBACK",
"to",
"ensure",
"that",
"transaction",
"state",
"invariants",
"are",
"maintained",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteSession.java#L869-L892 |
28,341 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DefaultDatabaseErrorHandler.java | DefaultDatabaseErrorHandler.onCorruption | public void onCorruption(SQLiteDatabase dbObj) {
Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());
// If this is a SEE build, do not delete any database files.
// It may be that the user has specified an incorrect password.
if( SQLiteDatabase.hasCodec() ) return;
// is the corruption detected even before database could be 'opened'?
if (!dbObj.isOpen()) {
// database files are not even openable. delete this database file.
// NOTE if the database has attached databases, then any of them could be corrupt.
// and not deleting all of them could cause corrupted database file to remain and
// make the application crash on database open operation. To avoid this problem,
// the application should provide its own {@link DatabaseErrorHandler} impl class
// to delete ALL files of the database (including the attached databases).
deleteDatabaseFile(dbObj.getPath());
return;
}
List<Pair<String, String>> attachedDbs = null;
try {
// Close the database, which will cause subsequent operations to fail.
// before that, get the attached database list first.
try {
attachedDbs = dbObj.getAttachedDbs();
} catch (SQLiteException e) {
/* ignore */
}
try {
dbObj.close();
} catch (SQLiteException e) {
/* ignore */
}
} finally {
// Delete all files of this corrupt database and/or attached databases
if (attachedDbs != null) {
for (Pair<String, String> p : attachedDbs) {
deleteDatabaseFile(p.second);
}
} else {
// attachedDbs = null is possible when the database is so corrupt that even
// "PRAGMA database_list;" also fails. delete the main database file
deleteDatabaseFile(dbObj.getPath());
}
}
} | java | public void onCorruption(SQLiteDatabase dbObj) {
Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());
// If this is a SEE build, do not delete any database files.
// It may be that the user has specified an incorrect password.
if( SQLiteDatabase.hasCodec() ) return;
// is the corruption detected even before database could be 'opened'?
if (!dbObj.isOpen()) {
// database files are not even openable. delete this database file.
// NOTE if the database has attached databases, then any of them could be corrupt.
// and not deleting all of them could cause corrupted database file to remain and
// make the application crash on database open operation. To avoid this problem,
// the application should provide its own {@link DatabaseErrorHandler} impl class
// to delete ALL files of the database (including the attached databases).
deleteDatabaseFile(dbObj.getPath());
return;
}
List<Pair<String, String>> attachedDbs = null;
try {
// Close the database, which will cause subsequent operations to fail.
// before that, get the attached database list first.
try {
attachedDbs = dbObj.getAttachedDbs();
} catch (SQLiteException e) {
/* ignore */
}
try {
dbObj.close();
} catch (SQLiteException e) {
/* ignore */
}
} finally {
// Delete all files of this corrupt database and/or attached databases
if (attachedDbs != null) {
for (Pair<String, String> p : attachedDbs) {
deleteDatabaseFile(p.second);
}
} else {
// attachedDbs = null is possible when the database is so corrupt that even
// "PRAGMA database_list;" also fails. delete the main database file
deleteDatabaseFile(dbObj.getPath());
}
}
} | [
"public",
"void",
"onCorruption",
"(",
"SQLiteDatabase",
"dbObj",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Corruption reported by sqlite on database: \"",
"+",
"dbObj",
".",
"getPath",
"(",
")",
")",
";",
"// If this is a SEE build, do not delete any database files.",
"// It may be that the user has specified an incorrect password.",
"if",
"(",
"SQLiteDatabase",
".",
"hasCodec",
"(",
")",
")",
"return",
";",
"// is the corruption detected even before database could be 'opened'?",
"if",
"(",
"!",
"dbObj",
".",
"isOpen",
"(",
")",
")",
"{",
"// database files are not even openable. delete this database file.",
"// NOTE if the database has attached databases, then any of them could be corrupt.",
"// and not deleting all of them could cause corrupted database file to remain and ",
"// make the application crash on database open operation. To avoid this problem,",
"// the application should provide its own {@link DatabaseErrorHandler} impl class",
"// to delete ALL files of the database (including the attached databases).",
"deleteDatabaseFile",
"(",
"dbObj",
".",
"getPath",
"(",
")",
")",
";",
"return",
";",
"}",
"List",
"<",
"Pair",
"<",
"String",
",",
"String",
">",
">",
"attachedDbs",
"=",
"null",
";",
"try",
"{",
"// Close the database, which will cause subsequent operations to fail.",
"// before that, get the attached database list first.",
"try",
"{",
"attachedDbs",
"=",
"dbObj",
".",
"getAttachedDbs",
"(",
")",
";",
"}",
"catch",
"(",
"SQLiteException",
"e",
")",
"{",
"/* ignore */",
"}",
"try",
"{",
"dbObj",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLiteException",
"e",
")",
"{",
"/* ignore */",
"}",
"}",
"finally",
"{",
"// Delete all files of this corrupt database and/or attached databases",
"if",
"(",
"attachedDbs",
"!=",
"null",
")",
"{",
"for",
"(",
"Pair",
"<",
"String",
",",
"String",
">",
"p",
":",
"attachedDbs",
")",
"{",
"deleteDatabaseFile",
"(",
"p",
".",
"second",
")",
";",
"}",
"}",
"else",
"{",
"// attachedDbs = null is possible when the database is so corrupt that even",
"// \"PRAGMA database_list;\" also fails. delete the main database file",
"deleteDatabaseFile",
"(",
"dbObj",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"}"
] | defines the default method to be invoked when database corruption is detected.
@param dbObj the {@link SQLiteDatabase} object representing the database on which corruption
is detected. | [
"defines",
"the",
"default",
"method",
"to",
"be",
"invoked",
"when",
"database",
"corruption",
"is",
"detected",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DefaultDatabaseErrorHandler.java#L58-L103 |
28,342 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnection.java | SQLiteConnection.executeForBlobFileDescriptor | public ParcelFileDescriptor executeForBlobFileDescriptor(String sql, Object[] bindArgs,
CancellationSignal cancellationSignal) {
if (sql == null) {
throw new IllegalArgumentException("sql must not be null.");
}
final int cookie = mRecentOperations.beginOperation("executeForBlobFileDescriptor",
sql, bindArgs);
try {
final PreparedStatement statement = acquirePreparedStatement(sql);
try {
throwIfStatementForbidden(statement);
bindArguments(statement, bindArgs);
applyBlockGuardPolicy(statement);
attachCancellationSignal(cancellationSignal);
try {
int fd = nativeExecuteForBlobFileDescriptor(
mConnectionPtr, statement.mStatementPtr);
return fd >= 0 ? ParcelFileDescriptor.adoptFd(fd) : null;
} finally {
detachCancellationSignal(cancellationSignal);
}
} finally {
releasePreparedStatement(statement);
}
} catch (RuntimeException ex) {
mRecentOperations.failOperation(cookie, ex);
throw ex;
} finally {
mRecentOperations.endOperation(cookie);
}
} | java | public ParcelFileDescriptor executeForBlobFileDescriptor(String sql, Object[] bindArgs,
CancellationSignal cancellationSignal) {
if (sql == null) {
throw new IllegalArgumentException("sql must not be null.");
}
final int cookie = mRecentOperations.beginOperation("executeForBlobFileDescriptor",
sql, bindArgs);
try {
final PreparedStatement statement = acquirePreparedStatement(sql);
try {
throwIfStatementForbidden(statement);
bindArguments(statement, bindArgs);
applyBlockGuardPolicy(statement);
attachCancellationSignal(cancellationSignal);
try {
int fd = nativeExecuteForBlobFileDescriptor(
mConnectionPtr, statement.mStatementPtr);
return fd >= 0 ? ParcelFileDescriptor.adoptFd(fd) : null;
} finally {
detachCancellationSignal(cancellationSignal);
}
} finally {
releasePreparedStatement(statement);
}
} catch (RuntimeException ex) {
mRecentOperations.failOperation(cookie, ex);
throw ex;
} finally {
mRecentOperations.endOperation(cookie);
}
} | [
"public",
"ParcelFileDescriptor",
"executeForBlobFileDescriptor",
"(",
"String",
"sql",
",",
"Object",
"[",
"]",
"bindArgs",
",",
"CancellationSignal",
"cancellationSignal",
")",
"{",
"if",
"(",
"sql",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"sql must not be null.\"",
")",
";",
"}",
"final",
"int",
"cookie",
"=",
"mRecentOperations",
".",
"beginOperation",
"(",
"\"executeForBlobFileDescriptor\"",
",",
"sql",
",",
"bindArgs",
")",
";",
"try",
"{",
"final",
"PreparedStatement",
"statement",
"=",
"acquirePreparedStatement",
"(",
"sql",
")",
";",
"try",
"{",
"throwIfStatementForbidden",
"(",
"statement",
")",
";",
"bindArguments",
"(",
"statement",
",",
"bindArgs",
")",
";",
"applyBlockGuardPolicy",
"(",
"statement",
")",
";",
"attachCancellationSignal",
"(",
"cancellationSignal",
")",
";",
"try",
"{",
"int",
"fd",
"=",
"nativeExecuteForBlobFileDescriptor",
"(",
"mConnectionPtr",
",",
"statement",
".",
"mStatementPtr",
")",
";",
"return",
"fd",
">=",
"0",
"?",
"ParcelFileDescriptor",
".",
"adoptFd",
"(",
"fd",
")",
":",
"null",
";",
"}",
"finally",
"{",
"detachCancellationSignal",
"(",
"cancellationSignal",
")",
";",
"}",
"}",
"finally",
"{",
"releasePreparedStatement",
"(",
"statement",
")",
";",
"}",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"mRecentOperations",
".",
"failOperation",
"(",
"cookie",
",",
"ex",
")",
";",
"throw",
"ex",
";",
"}",
"finally",
"{",
"mRecentOperations",
".",
"endOperation",
"(",
"cookie",
")",
";",
"}",
"}"
] | Executes a statement that returns a single BLOB result as a
file descriptor to a shared memory region.
@param sql The SQL statement to execute.
@param bindArgs The arguments to bind, or null if none.
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
@return The file descriptor for a shared memory region that contains
the value of the first column in the first row of the result set as a BLOB,
or null if none.
@throws SQLiteException if an error occurs, such as a syntax error
or invalid number of bind arguments.
@throws OperationCanceledException if the operation was canceled. | [
"Executes",
"a",
"statement",
"that",
"returns",
"a",
"single",
"BLOB",
"result",
"as",
"a",
"file",
"descriptor",
"to",
"a",
"shared",
"memory",
"region",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnection.java#L683-L714 |
28,343 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnection.java | SQLiteConnection.executeForChangedRowCount | public int executeForChangedRowCount(String sql, Object[] bindArgs,
CancellationSignal cancellationSignal) {
if (sql == null) {
throw new IllegalArgumentException("sql must not be null.");
}
int changedRows = 0;
final int cookie = mRecentOperations.beginOperation("executeForChangedRowCount",
sql, bindArgs);
try {
final PreparedStatement statement = acquirePreparedStatement(sql);
try {
throwIfStatementForbidden(statement);
bindArguments(statement, bindArgs);
applyBlockGuardPolicy(statement);
attachCancellationSignal(cancellationSignal);
try {
changedRows = nativeExecuteForChangedRowCount(
mConnectionPtr, statement.mStatementPtr);
return changedRows;
} finally {
detachCancellationSignal(cancellationSignal);
}
} finally {
releasePreparedStatement(statement);
}
} catch (RuntimeException ex) {
mRecentOperations.failOperation(cookie, ex);
throw ex;
} finally {
if (mRecentOperations.endOperationDeferLog(cookie)) {
mRecentOperations.logOperation(cookie, "changedRows=" + changedRows);
}
}
} | java | public int executeForChangedRowCount(String sql, Object[] bindArgs,
CancellationSignal cancellationSignal) {
if (sql == null) {
throw new IllegalArgumentException("sql must not be null.");
}
int changedRows = 0;
final int cookie = mRecentOperations.beginOperation("executeForChangedRowCount",
sql, bindArgs);
try {
final PreparedStatement statement = acquirePreparedStatement(sql);
try {
throwIfStatementForbidden(statement);
bindArguments(statement, bindArgs);
applyBlockGuardPolicy(statement);
attachCancellationSignal(cancellationSignal);
try {
changedRows = nativeExecuteForChangedRowCount(
mConnectionPtr, statement.mStatementPtr);
return changedRows;
} finally {
detachCancellationSignal(cancellationSignal);
}
} finally {
releasePreparedStatement(statement);
}
} catch (RuntimeException ex) {
mRecentOperations.failOperation(cookie, ex);
throw ex;
} finally {
if (mRecentOperations.endOperationDeferLog(cookie)) {
mRecentOperations.logOperation(cookie, "changedRows=" + changedRows);
}
}
} | [
"public",
"int",
"executeForChangedRowCount",
"(",
"String",
"sql",
",",
"Object",
"[",
"]",
"bindArgs",
",",
"CancellationSignal",
"cancellationSignal",
")",
"{",
"if",
"(",
"sql",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"sql must not be null.\"",
")",
";",
"}",
"int",
"changedRows",
"=",
"0",
";",
"final",
"int",
"cookie",
"=",
"mRecentOperations",
".",
"beginOperation",
"(",
"\"executeForChangedRowCount\"",
",",
"sql",
",",
"bindArgs",
")",
";",
"try",
"{",
"final",
"PreparedStatement",
"statement",
"=",
"acquirePreparedStatement",
"(",
"sql",
")",
";",
"try",
"{",
"throwIfStatementForbidden",
"(",
"statement",
")",
";",
"bindArguments",
"(",
"statement",
",",
"bindArgs",
")",
";",
"applyBlockGuardPolicy",
"(",
"statement",
")",
";",
"attachCancellationSignal",
"(",
"cancellationSignal",
")",
";",
"try",
"{",
"changedRows",
"=",
"nativeExecuteForChangedRowCount",
"(",
"mConnectionPtr",
",",
"statement",
".",
"mStatementPtr",
")",
";",
"return",
"changedRows",
";",
"}",
"finally",
"{",
"detachCancellationSignal",
"(",
"cancellationSignal",
")",
";",
"}",
"}",
"finally",
"{",
"releasePreparedStatement",
"(",
"statement",
")",
";",
"}",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"mRecentOperations",
".",
"failOperation",
"(",
"cookie",
",",
"ex",
")",
";",
"throw",
"ex",
";",
"}",
"finally",
"{",
"if",
"(",
"mRecentOperations",
".",
"endOperationDeferLog",
"(",
"cookie",
")",
")",
"{",
"mRecentOperations",
".",
"logOperation",
"(",
"cookie",
",",
"\"changedRows=\"",
"+",
"changedRows",
")",
";",
"}",
"}",
"}"
] | Executes a statement that returns a count of the number of rows
that were changed. Use for UPDATE or DELETE SQL statements.
@param sql The SQL statement to execute.
@param bindArgs The arguments to bind, or null if none.
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
@return The number of rows that were changed.
@throws SQLiteException if an error occurs, such as a syntax error
or invalid number of bind arguments.
@throws OperationCanceledException if the operation was canceled. | [
"Executes",
"a",
"statement",
"that",
"returns",
"a",
"count",
"of",
"the",
"number",
"of",
"rows",
"that",
"were",
"changed",
".",
"Use",
"for",
"UPDATE",
"or",
"DELETE",
"SQL",
"statements",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnection.java#L729-L763 |
28,344 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/datastore/MultiMapDataStore.java | MultiMapDataStore.addMapDataStore | public void addMapDataStore(MapDataStore mapDataStore, boolean useStartZoomLevel, boolean useStartPosition) {
if (this.mapDatabases.contains(mapDataStore)) {
throw new IllegalArgumentException("Duplicate map database");
}
this.mapDatabases.add(mapDataStore);
if (useStartZoomLevel) {
this.startZoomLevel = mapDataStore.startZoomLevel();
}
if (useStartPosition) {
this.startPosition = mapDataStore.startPosition();
}
if (null == this.boundingBox) {
this.boundingBox = mapDataStore.boundingBox();
} else {
this.boundingBox = this.boundingBox.extendBoundingBox(mapDataStore.boundingBox());
}
} | java | public void addMapDataStore(MapDataStore mapDataStore, boolean useStartZoomLevel, boolean useStartPosition) {
if (this.mapDatabases.contains(mapDataStore)) {
throw new IllegalArgumentException("Duplicate map database");
}
this.mapDatabases.add(mapDataStore);
if (useStartZoomLevel) {
this.startZoomLevel = mapDataStore.startZoomLevel();
}
if (useStartPosition) {
this.startPosition = mapDataStore.startPosition();
}
if (null == this.boundingBox) {
this.boundingBox = mapDataStore.boundingBox();
} else {
this.boundingBox = this.boundingBox.extendBoundingBox(mapDataStore.boundingBox());
}
} | [
"public",
"void",
"addMapDataStore",
"(",
"MapDataStore",
"mapDataStore",
",",
"boolean",
"useStartZoomLevel",
",",
"boolean",
"useStartPosition",
")",
"{",
"if",
"(",
"this",
".",
"mapDatabases",
".",
"contains",
"(",
"mapDataStore",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Duplicate map database\"",
")",
";",
"}",
"this",
".",
"mapDatabases",
".",
"add",
"(",
"mapDataStore",
")",
";",
"if",
"(",
"useStartZoomLevel",
")",
"{",
"this",
".",
"startZoomLevel",
"=",
"mapDataStore",
".",
"startZoomLevel",
"(",
")",
";",
"}",
"if",
"(",
"useStartPosition",
")",
"{",
"this",
".",
"startPosition",
"=",
"mapDataStore",
".",
"startPosition",
"(",
")",
";",
"}",
"if",
"(",
"null",
"==",
"this",
".",
"boundingBox",
")",
"{",
"this",
".",
"boundingBox",
"=",
"mapDataStore",
".",
"boundingBox",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"boundingBox",
"=",
"this",
".",
"boundingBox",
".",
"extendBoundingBox",
"(",
"mapDataStore",
".",
"boundingBox",
"(",
")",
")",
";",
"}",
"}"
] | adds another mapDataStore
@param mapDataStore the mapDataStore to add
@param useStartZoomLevel if true, use the start zoom level of this mapDataStore as the start zoom level
@param useStartPosition if true, use the start position of this mapDataStore as the start position | [
"adds",
"another",
"mapDataStore"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/datastore/MultiMapDataStore.java#L65-L81 |
28,345 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteProgram.java | SQLiteProgram.bindAllArgsAsStrings | public void bindAllArgsAsStrings(String[] bindArgs) {
if (bindArgs != null) {
for (int i = bindArgs.length; i != 0; i--) {
bindString(i, bindArgs[i - 1]);
}
}
} | java | public void bindAllArgsAsStrings(String[] bindArgs) {
if (bindArgs != null) {
for (int i = bindArgs.length; i != 0; i--) {
bindString(i, bindArgs[i - 1]);
}
}
} | [
"public",
"void",
"bindAllArgsAsStrings",
"(",
"String",
"[",
"]",
"bindArgs",
")",
"{",
"if",
"(",
"bindArgs",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"bindArgs",
".",
"length",
";",
"i",
"!=",
"0",
";",
"i",
"--",
")",
"{",
"bindString",
"(",
"i",
",",
"bindArgs",
"[",
"i",
"-",
"1",
"]",
")",
";",
"}",
"}",
"}"
] | Given an array of String bindArgs, this method binds all of them in one single call.
@param bindArgs the String array of bind args, none of which must be null. | [
"Given",
"an",
"array",
"of",
"String",
"bindArgs",
"this",
"method",
"binds",
"all",
"of",
"them",
"in",
"one",
"single",
"call",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteProgram.java#L201-L207 |
28,346 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/CloseGuard.java | CloseGuard.warnIfOpen | public void warnIfOpen() {
if (allocationSite == null || !ENABLED) {
return;
}
String message =
("A resource was acquired at attached stack trace but never released. "
+ "See java.io.Closeable for information on avoiding resource leaks.");
REPORTER.report(message, allocationSite);
} | java | public void warnIfOpen() {
if (allocationSite == null || !ENABLED) {
return;
}
String message =
("A resource was acquired at attached stack trace but never released. "
+ "See java.io.Closeable for information on avoiding resource leaks.");
REPORTER.report(message, allocationSite);
} | [
"public",
"void",
"warnIfOpen",
"(",
")",
"{",
"if",
"(",
"allocationSite",
"==",
"null",
"||",
"!",
"ENABLED",
")",
"{",
"return",
";",
"}",
"String",
"message",
"=",
"(",
"\"A resource was acquired at attached stack trace but never released. \"",
"+",
"\"See java.io.Closeable for information on avoiding resource leaks.\"",
")",
";",
"REPORTER",
".",
"report",
"(",
"message",
",",
"allocationSite",
")",
";",
"}"
] | If CloseGuard is enabled, logs a warning if the caller did not
properly cleanup by calling an explicit close method
before finalization. If CloseGuard is disabled, no action is
performed. | [
"If",
"CloseGuard",
"is",
"enabled",
"logs",
"a",
"warning",
"if",
"the",
"caller",
"did",
"not",
"properly",
"cleanup",
"by",
"calling",
"an",
"explicit",
"close",
"method",
"before",
"finalization",
".",
"If",
"CloseGuard",
"is",
"disabled",
"no",
"action",
"is",
"performed",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/CloseGuard.java#L208-L218 |
28,347 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LatLong.java | LatLong.compareTo | @Override
public int compareTo(LatLong latLong) {
if (this.latitude > latLong.latitude || this.longitude > latLong.longitude) {
return 1;
} else if (this.latitude < latLong.latitude
|| this.longitude < latLong.longitude) {
return -1;
}
return 0;
} | java | @Override
public int compareTo(LatLong latLong) {
if (this.latitude > latLong.latitude || this.longitude > latLong.longitude) {
return 1;
} else if (this.latitude < latLong.latitude
|| this.longitude < latLong.longitude) {
return -1;
}
return 0;
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"LatLong",
"latLong",
")",
"{",
"if",
"(",
"this",
".",
"latitude",
">",
"latLong",
".",
"latitude",
"||",
"this",
".",
"longitude",
">",
"latLong",
".",
"longitude",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"this",
".",
"latitude",
"<",
"latLong",
".",
"latitude",
"||",
"this",
".",
"longitude",
"<",
"latLong",
".",
"longitude",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | This method is necessary for inserting LatLongs into tree data structures. | [
"This",
"method",
"is",
"necessary",
"for",
"inserting",
"LatLongs",
"into",
"tree",
"data",
"structures",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LatLong.java#L76-L85 |
28,348 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/LatLong.java | LatLong.fromMicroDegrees | public static LatLong fromMicroDegrees(int latitudeE6, int longitudeE6) {
return new LatLong(LatLongUtils.microdegreesToDegrees(latitudeE6),
LatLongUtils.microdegreesToDegrees(longitudeE6));
} | java | public static LatLong fromMicroDegrees(int latitudeE6, int longitudeE6) {
return new LatLong(LatLongUtils.microdegreesToDegrees(latitudeE6),
LatLongUtils.microdegreesToDegrees(longitudeE6));
} | [
"public",
"static",
"LatLong",
"fromMicroDegrees",
"(",
"int",
"latitudeE6",
",",
"int",
"longitudeE6",
")",
"{",
"return",
"new",
"LatLong",
"(",
"LatLongUtils",
".",
"microdegreesToDegrees",
"(",
"latitudeE6",
")",
",",
"LatLongUtils",
".",
"microdegreesToDegrees",
"(",
"longitudeE6",
")",
")",
";",
"}"
] | Constructs a new LatLong with the given latitude and longitude values, measured in
microdegrees.
@param latitudeE6 the latitude value in microdegrees.
@param longitudeE6 the longitude value in microdegrees.
@return the LatLong
@throws IllegalArgumentException if the latitudeE6 or longitudeE6 value is invalid. | [
"Constructs",
"a",
"new",
"LatLong",
"with",
"the",
"given",
"latitude",
"and",
"longitude",
"values",
"measured",
"in",
"microdegrees",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/LatLong.java#L136-L139 |
28,349 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SimplestMapViewer.java | SimplestMapViewer.createLayers | @Override
protected void createLayers() {
TileRendererLayer tileRendererLayer = AndroidUtil.createTileRendererLayer(this.tileCaches.get(0),
this.mapView.getModel().mapViewPosition, getMapFile(), getRenderTheme(), false, true, false);
this.mapView.getLayerManager().getLayers().add(tileRendererLayer);
} | java | @Override
protected void createLayers() {
TileRendererLayer tileRendererLayer = AndroidUtil.createTileRendererLayer(this.tileCaches.get(0),
this.mapView.getModel().mapViewPosition, getMapFile(), getRenderTheme(), false, true, false);
this.mapView.getLayerManager().getLayers().add(tileRendererLayer);
} | [
"@",
"Override",
"protected",
"void",
"createLayers",
"(",
")",
"{",
"TileRendererLayer",
"tileRendererLayer",
"=",
"AndroidUtil",
".",
"createTileRendererLayer",
"(",
"this",
".",
"tileCaches",
".",
"get",
"(",
"0",
")",
",",
"this",
".",
"mapView",
".",
"getModel",
"(",
")",
".",
"mapViewPosition",
",",
"getMapFile",
"(",
")",
",",
"getRenderTheme",
"(",
")",
",",
"false",
",",
"true",
",",
"false",
")",
";",
"this",
".",
"mapView",
".",
"getLayerManager",
"(",
")",
".",
"getLayers",
"(",
")",
".",
"add",
"(",
"tileRendererLayer",
")",
";",
"}"
] | Creates a simple tile renderer layer with the AndroidUtil helper. | [
"Creates",
"a",
"simple",
"tile",
"renderer",
"layer",
"with",
"the",
"AndroidUtil",
"helper",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SimplestMapViewer.java#L76-L81 |
28,350 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SimplestMapViewer.java | SimplestMapViewer.createTileCaches | @Override
protected void createTileCaches() {
this.tileCaches.add(AndroidUtil.createTileCache(this, getPersistableId(),
this.mapView.getModel().displayModel.getTileSize(), this.getScreenRatio(),
this.mapView.getModel().frameBufferModel.getOverdrawFactor()));
} | java | @Override
protected void createTileCaches() {
this.tileCaches.add(AndroidUtil.createTileCache(this, getPersistableId(),
this.mapView.getModel().displayModel.getTileSize(), this.getScreenRatio(),
this.mapView.getModel().frameBufferModel.getOverdrawFactor()));
} | [
"@",
"Override",
"protected",
"void",
"createTileCaches",
"(",
")",
"{",
"this",
".",
"tileCaches",
".",
"add",
"(",
"AndroidUtil",
".",
"createTileCache",
"(",
"this",
",",
"getPersistableId",
"(",
")",
",",
"this",
".",
"mapView",
".",
"getModel",
"(",
")",
".",
"displayModel",
".",
"getTileSize",
"(",
")",
",",
"this",
".",
"getScreenRatio",
"(",
")",
",",
"this",
".",
"mapView",
".",
"getModel",
"(",
")",
".",
"frameBufferModel",
".",
"getOverdrawFactor",
"(",
")",
")",
")",
";",
"}"
] | Creates the tile cache with the AndroidUtil helper | [
"Creates",
"the",
"tile",
"cache",
"with",
"the",
"AndroidUtil",
"helper"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SimplestMapViewer.java#L91-L96 |
28,351 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getBoundingBox | public static BoundingBox getBoundingBox(Tile upperLeft, Tile lowerRight) {
BoundingBox ul = upperLeft.getBoundingBox();
BoundingBox lr = lowerRight.getBoundingBox();
return ul.extendBoundingBox(lr);
} | java | public static BoundingBox getBoundingBox(Tile upperLeft, Tile lowerRight) {
BoundingBox ul = upperLeft.getBoundingBox();
BoundingBox lr = lowerRight.getBoundingBox();
return ul.extendBoundingBox(lr);
} | [
"public",
"static",
"BoundingBox",
"getBoundingBox",
"(",
"Tile",
"upperLeft",
",",
"Tile",
"lowerRight",
")",
"{",
"BoundingBox",
"ul",
"=",
"upperLeft",
".",
"getBoundingBox",
"(",
")",
";",
"BoundingBox",
"lr",
"=",
"lowerRight",
".",
"getBoundingBox",
"(",
")",
";",
"return",
"ul",
".",
"extendBoundingBox",
"(",
"lr",
")",
";",
"}"
] | Return the BoundingBox of a rectangle of tiles defined by upper left and lower right tile.
@param upperLeft tile in upper left corner.
@param lowerRight tile in lower right corner.
@return BoundingBox defined by the area around upperLeft and lowerRight Tile. | [
"Return",
"the",
"BoundingBox",
"of",
"a",
"rectangle",
"of",
"tiles",
"defined",
"by",
"upper",
"left",
"and",
"lower",
"right",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L38-L42 |
28,352 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getBoundaryAbsolute | public static Rectangle getBoundaryAbsolute(Tile upperLeft, Tile lowerRight) {
return new Rectangle(upperLeft.getOrigin().x, upperLeft.getOrigin().y, lowerRight.getOrigin().x + upperLeft.tileSize, lowerRight.getOrigin().y + upperLeft.tileSize);
} | java | public static Rectangle getBoundaryAbsolute(Tile upperLeft, Tile lowerRight) {
return new Rectangle(upperLeft.getOrigin().x, upperLeft.getOrigin().y, lowerRight.getOrigin().x + upperLeft.tileSize, lowerRight.getOrigin().y + upperLeft.tileSize);
} | [
"public",
"static",
"Rectangle",
"getBoundaryAbsolute",
"(",
"Tile",
"upperLeft",
",",
"Tile",
"lowerRight",
")",
"{",
"return",
"new",
"Rectangle",
"(",
"upperLeft",
".",
"getOrigin",
"(",
")",
".",
"x",
",",
"upperLeft",
".",
"getOrigin",
"(",
")",
".",
"y",
",",
"lowerRight",
".",
"getOrigin",
"(",
")",
".",
"x",
"+",
"upperLeft",
".",
"tileSize",
",",
"lowerRight",
".",
"getOrigin",
"(",
")",
".",
"y",
"+",
"upperLeft",
".",
"tileSize",
")",
";",
"}"
] | Extend of the area defined by the two tiles in absolute coordinates.
@param upperLeft tile in upper left corner of area.
@param lowerRight tile in lower right corner of area.
@return rectangle with the absolute coordinates. | [
"Extend",
"of",
"the",
"area",
"defined",
"by",
"the",
"two",
"tiles",
"in",
"absolute",
"coordinates",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L51-L53 |
28,353 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getBoundingBox | public BoundingBox getBoundingBox() {
if (this.boundingBox == null) {
double minLatitude = Math.max(MercatorProjection.LATITUDE_MIN, MercatorProjection.tileYToLatitude(tileY + 1, zoomLevel));
double minLongitude = Math.max(-180, MercatorProjection.tileXToLongitude(this.tileX, zoomLevel));
double maxLatitude = Math.min(MercatorProjection.LATITUDE_MAX, MercatorProjection.tileYToLatitude(this.tileY, zoomLevel));
double maxLongitude = Math.min(180, MercatorProjection.tileXToLongitude(tileX + 1, zoomLevel));
if (maxLongitude == -180) {
// fix for dateline crossing, where the right tile starts at -180 and causes an invalid bbox
maxLongitude = 180;
}
this.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
}
return this.boundingBox;
} | java | public BoundingBox getBoundingBox() {
if (this.boundingBox == null) {
double minLatitude = Math.max(MercatorProjection.LATITUDE_MIN, MercatorProjection.tileYToLatitude(tileY + 1, zoomLevel));
double minLongitude = Math.max(-180, MercatorProjection.tileXToLongitude(this.tileX, zoomLevel));
double maxLatitude = Math.min(MercatorProjection.LATITUDE_MAX, MercatorProjection.tileYToLatitude(this.tileY, zoomLevel));
double maxLongitude = Math.min(180, MercatorProjection.tileXToLongitude(tileX + 1, zoomLevel));
if (maxLongitude == -180) {
// fix for dateline crossing, where the right tile starts at -180 and causes an invalid bbox
maxLongitude = 180;
}
this.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
}
return this.boundingBox;
} | [
"public",
"BoundingBox",
"getBoundingBox",
"(",
")",
"{",
"if",
"(",
"this",
".",
"boundingBox",
"==",
"null",
")",
"{",
"double",
"minLatitude",
"=",
"Math",
".",
"max",
"(",
"MercatorProjection",
".",
"LATITUDE_MIN",
",",
"MercatorProjection",
".",
"tileYToLatitude",
"(",
"tileY",
"+",
"1",
",",
"zoomLevel",
")",
")",
";",
"double",
"minLongitude",
"=",
"Math",
".",
"max",
"(",
"-",
"180",
",",
"MercatorProjection",
".",
"tileXToLongitude",
"(",
"this",
".",
"tileX",
",",
"zoomLevel",
")",
")",
";",
"double",
"maxLatitude",
"=",
"Math",
".",
"min",
"(",
"MercatorProjection",
".",
"LATITUDE_MAX",
",",
"MercatorProjection",
".",
"tileYToLatitude",
"(",
"this",
".",
"tileY",
",",
"zoomLevel",
")",
")",
";",
"double",
"maxLongitude",
"=",
"Math",
".",
"min",
"(",
"180",
",",
"MercatorProjection",
".",
"tileXToLongitude",
"(",
"tileX",
"+",
"1",
",",
"zoomLevel",
")",
")",
";",
"if",
"(",
"maxLongitude",
"==",
"-",
"180",
")",
"{",
"// fix for dateline crossing, where the right tile starts at -180 and causes an invalid bbox",
"maxLongitude",
"=",
"180",
";",
"}",
"this",
".",
"boundingBox",
"=",
"new",
"BoundingBox",
"(",
"minLatitude",
",",
"minLongitude",
",",
"maxLatitude",
",",
"maxLongitude",
")",
";",
"}",
"return",
"this",
".",
"boundingBox",
";",
"}"
] | Gets the geographic extend of this Tile as a BoundingBox.
@return boundaries of this tile. | [
"Gets",
"the",
"geographic",
"extend",
"of",
"this",
"Tile",
"as",
"a",
"BoundingBox",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L170-L183 |
28,354 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getNeighbours | public Set<Tile> getNeighbours() {
Set<Tile> neighbours = new HashSet<Tile>(8);
neighbours.add(getLeft());
neighbours.add(getAboveLeft());
neighbours.add(getAbove());
neighbours.add(getAboveRight());
neighbours.add(getRight());
neighbours.add(getBelowRight());
neighbours.add(getBelow());
neighbours.add(getBelowLeft());
return neighbours;
} | java | public Set<Tile> getNeighbours() {
Set<Tile> neighbours = new HashSet<Tile>(8);
neighbours.add(getLeft());
neighbours.add(getAboveLeft());
neighbours.add(getAbove());
neighbours.add(getAboveRight());
neighbours.add(getRight());
neighbours.add(getBelowRight());
neighbours.add(getBelow());
neighbours.add(getBelowLeft());
return neighbours;
} | [
"public",
"Set",
"<",
"Tile",
">",
"getNeighbours",
"(",
")",
"{",
"Set",
"<",
"Tile",
">",
"neighbours",
"=",
"new",
"HashSet",
"<",
"Tile",
">",
"(",
"8",
")",
";",
"neighbours",
".",
"add",
"(",
"getLeft",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getAboveLeft",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getAbove",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getAboveRight",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getRight",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getBelowRight",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getBelow",
"(",
")",
")",
";",
"neighbours",
".",
"add",
"(",
"getBelowLeft",
"(",
")",
")",
";",
"return",
"neighbours",
";",
"}"
] | Returns a set of the eight neighbours of this tile.
@return neighbour tiles as a set | [
"Returns",
"a",
"set",
"of",
"the",
"eight",
"neighbours",
"of",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L190-L201 |
28,355 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getBoundaryAbsolute | public Rectangle getBoundaryAbsolute() {
return new Rectangle(getOrigin().x, getOrigin().y, getOrigin().x + tileSize, getOrigin().y + tileSize);
} | java | public Rectangle getBoundaryAbsolute() {
return new Rectangle(getOrigin().x, getOrigin().y, getOrigin().x + tileSize, getOrigin().y + tileSize);
} | [
"public",
"Rectangle",
"getBoundaryAbsolute",
"(",
")",
"{",
"return",
"new",
"Rectangle",
"(",
"getOrigin",
"(",
")",
".",
"x",
",",
"getOrigin",
"(",
")",
".",
"y",
",",
"getOrigin",
"(",
")",
".",
"x",
"+",
"tileSize",
",",
"getOrigin",
"(",
")",
".",
"y",
"+",
"tileSize",
")",
";",
"}"
] | Extend of this tile in absolute coordinates.
@return rectangle with the absolute coordinates. | [
"Extend",
"of",
"this",
"tile",
"in",
"absolute",
"coordinates",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L208-L210 |
28,356 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getOrigin | public Point getOrigin() {
if (this.origin == null) {
double x = MercatorProjection.tileToPixel(this.tileX, this.tileSize);
double y = MercatorProjection.tileToPixel(this.tileY, this.tileSize);
this.origin = new Point(x, y);
}
return this.origin;
} | java | public Point getOrigin() {
if (this.origin == null) {
double x = MercatorProjection.tileToPixel(this.tileX, this.tileSize);
double y = MercatorProjection.tileToPixel(this.tileY, this.tileSize);
this.origin = new Point(x, y);
}
return this.origin;
} | [
"public",
"Point",
"getOrigin",
"(",
")",
"{",
"if",
"(",
"this",
".",
"origin",
"==",
"null",
")",
"{",
"double",
"x",
"=",
"MercatorProjection",
".",
"tileToPixel",
"(",
"this",
".",
"tileX",
",",
"this",
".",
"tileSize",
")",
";",
"double",
"y",
"=",
"MercatorProjection",
".",
"tileToPixel",
"(",
"this",
".",
"tileY",
",",
"this",
".",
"tileSize",
")",
";",
"this",
".",
"origin",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"}",
"return",
"this",
".",
"origin",
";",
"}"
] | Returns the top-left point of this tile in absolute coordinates.
@return the top-left point | [
"Returns",
"the",
"top",
"-",
"left",
"point",
"of",
"this",
"tile",
"in",
"absolute",
"coordinates",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L227-L234 |
28,357 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getLeft | public Tile getLeft() {
int x = tileX - 1;
if (x < 0) {
x = getMaxTileNumber(this.zoomLevel);
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | java | public Tile getLeft() {
int x = tileX - 1;
if (x < 0) {
x = getMaxTileNumber(this.zoomLevel);
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getLeft",
"(",
")",
"{",
"int",
"x",
"=",
"tileX",
"-",
"1",
";",
"if",
"(",
"x",
"<",
"0",
")",
"{",
"x",
"=",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
";",
"}",
"return",
"new",
"Tile",
"(",
"x",
",",
"this",
".",
"tileY",
",",
"this",
".",
"zoomLevel",
",",
"this",
".",
"tileSize",
")",
";",
"}"
] | Returns the tile to the left of this tile.
@return tile to the left. | [
"Returns",
"the",
"tile",
"to",
"the",
"left",
"of",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L241-L247 |
28,358 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getRight | public Tile getRight() {
int x = tileX + 1;
if (x > getMaxTileNumber(this.zoomLevel)) {
x = 0;
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | java | public Tile getRight() {
int x = tileX + 1;
if (x > getMaxTileNumber(this.zoomLevel)) {
x = 0;
}
return new Tile(x, this.tileY, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getRight",
"(",
")",
"{",
"int",
"x",
"=",
"tileX",
"+",
"1",
";",
"if",
"(",
"x",
">",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
")",
"{",
"x",
"=",
"0",
";",
"}",
"return",
"new",
"Tile",
"(",
"x",
",",
"this",
".",
"tileY",
",",
"this",
".",
"zoomLevel",
",",
"this",
".",
"tileSize",
")",
";",
"}"
] | Returns the tile to the right of this tile.
@return tile to the right | [
"Returns",
"the",
"tile",
"to",
"the",
"right",
"of",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L254-L260 |
28,359 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getAbove | public Tile getAbove() {
int y = tileY - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel);
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} | java | public Tile getAbove() {
int y = tileY - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel);
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getAbove",
"(",
")",
"{",
"int",
"y",
"=",
"tileY",
"-",
"1",
";",
"if",
"(",
"y",
"<",
"0",
")",
"{",
"y",
"=",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
";",
"}",
"return",
"new",
"Tile",
"(",
"this",
".",
"tileX",
",",
"y",
",",
"this",
".",
"zoomLevel",
",",
"this",
".",
"tileSize",
")",
";",
"}"
] | Returns the tile above this tile.
@return tile above | [
"Returns",
"the",
"tile",
"above",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L267-L273 |
28,360 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getBelow | public Tile getBelow() {
int y = tileY + 1;
if (y > getMaxTileNumber(this.zoomLevel)) {
y = 0;
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} | java | public Tile getBelow() {
int y = tileY + 1;
if (y > getMaxTileNumber(this.zoomLevel)) {
y = 0;
}
return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getBelow",
"(",
")",
"{",
"int",
"y",
"=",
"tileY",
"+",
"1",
";",
"if",
"(",
"y",
">",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
")",
"{",
"y",
"=",
"0",
";",
"}",
"return",
"new",
"Tile",
"(",
"this",
".",
"tileX",
",",
"y",
",",
"this",
".",
"zoomLevel",
",",
"this",
".",
"tileSize",
")",
";",
"}"
] | Returns the tile below this tile.
@return tile below | [
"Returns",
"the",
"tile",
"below",
"this",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L281-L287 |
28,361 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java | Tile.getAboveLeft | public Tile getAboveLeft() {
int y = tileY - 1;
int x = tileX - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel);
}
if (x < 0) {
x = getMaxTileNumber(this.zoomLevel);
}
return new Tile(x, y, this.zoomLevel, this.tileSize);
} | java | public Tile getAboveLeft() {
int y = tileY - 1;
int x = tileX - 1;
if (y < 0) {
y = getMaxTileNumber(this.zoomLevel);
}
if (x < 0) {
x = getMaxTileNumber(this.zoomLevel);
}
return new Tile(x, y, this.zoomLevel, this.tileSize);
} | [
"public",
"Tile",
"getAboveLeft",
"(",
")",
"{",
"int",
"y",
"=",
"tileY",
"-",
"1",
";",
"int",
"x",
"=",
"tileX",
"-",
"1",
";",
"if",
"(",
"y",
"<",
"0",
")",
"{",
"y",
"=",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
";",
"}",
"if",
"(",
"x",
"<",
"0",
")",
"{",
"x",
"=",
"getMaxTileNumber",
"(",
"this",
".",
"zoomLevel",
")",
";",
"}",
"return",
"new",
"Tile",
"(",
"x",
",",
"y",
",",
"this",
".",
"zoomLevel",
",",
"this",
".",
"tileSize",
")",
";",
"}"
] | Returns the tile above left
@return tile above left | [
"Returns",
"the",
"tile",
"above",
"left"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/Tile.java#L294-L304 |
28,362 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/group/ChildMarker.java | ChildMarker.init | public void init(int index, Bitmap bitmap, int horizontalOffset, int verticalOffset) {
this.index = index;
this.groupBitmapHalfHeight = bitmap.getHeight() / 2;
this.groupBitmapHalfWidth = bitmap.getWidth() / 2;
this.groupHOffset = horizontalOffset;
this.groupVOffset = verticalOffset;
} | java | public void init(int index, Bitmap bitmap, int horizontalOffset, int verticalOffset) {
this.index = index;
this.groupBitmapHalfHeight = bitmap.getHeight() / 2;
this.groupBitmapHalfWidth = bitmap.getWidth() / 2;
this.groupHOffset = horizontalOffset;
this.groupVOffset = verticalOffset;
} | [
"public",
"void",
"init",
"(",
"int",
"index",
",",
"Bitmap",
"bitmap",
",",
"int",
"horizontalOffset",
",",
"int",
"verticalOffset",
")",
"{",
"this",
".",
"index",
"=",
"index",
";",
"this",
".",
"groupBitmapHalfHeight",
"=",
"bitmap",
".",
"getHeight",
"(",
")",
"/",
"2",
";",
"this",
".",
"groupBitmapHalfWidth",
"=",
"bitmap",
".",
"getWidth",
"(",
")",
"/",
"2",
";",
"this",
".",
"groupHOffset",
"=",
"horizontalOffset",
";",
"this",
".",
"groupVOffset",
"=",
"verticalOffset",
";",
"}"
] | Set group marker parameter. To know index and calculate position on spiral.
@param index the index of this child marker.
@param bitmap the bitmap of the group marker.
@param horizontalOffset the horizontal offset of the group marker.
@param verticalOffset the vertical offset of the group marker. | [
"Set",
"group",
"marker",
"parameter",
".",
"To",
"know",
"index",
"and",
"calculate",
"position",
"on",
"spiral",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/group/ChildMarker.java#L125-L132 |
28,363 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java | BaseTileBasedDataProcessor.addImplicitRelationInformation | protected void addImplicitRelationInformation(TDWay tdWay) {
if (!this.tagValues) {
return;
}
// FEATURE Remove this to add id to all elements (increase of space around 1/8)
if (!this.partRootRelations.containsKey(tdWay.getId())) {
return;
}
Long rootId = this.partRootRelations.get(tdWay.getId());
if (rootId == null) {
OSMTagMapping mapping = OSMTagMapping.getInstance();
// Remove accidentally written ids in OSM
for (Short aShort : tdWay.getTags().keySet()) {
if (mapping.getWayTag(aShort).getKey().equals("id")) {
tdWay.getTags().remove(aShort);
break;
}
}
// Add id to root element (respecting tag-mapping file)
OSMTag idTag = mapping.getWayTag("id", String.valueOf(tdWay.getId()));
assert idTag != null;
tdWay.getTags().put(idTag.getId(), OSMUtils.getObjectFromWildcardAndValue(idTag.getValue(), String.valueOf(tdWay.getId())));
} else {
// Add reference id to part element
tdWay.setRef(String.valueOf(rootId));
}
// #HDstoreData: Removing not possible, because HD' tiles need them multiple times (for count and processing)
// partRootRelations.remove(tdWay.getId());
} | java | protected void addImplicitRelationInformation(TDWay tdWay) {
if (!this.tagValues) {
return;
}
// FEATURE Remove this to add id to all elements (increase of space around 1/8)
if (!this.partRootRelations.containsKey(tdWay.getId())) {
return;
}
Long rootId = this.partRootRelations.get(tdWay.getId());
if (rootId == null) {
OSMTagMapping mapping = OSMTagMapping.getInstance();
// Remove accidentally written ids in OSM
for (Short aShort : tdWay.getTags().keySet()) {
if (mapping.getWayTag(aShort).getKey().equals("id")) {
tdWay.getTags().remove(aShort);
break;
}
}
// Add id to root element (respecting tag-mapping file)
OSMTag idTag = mapping.getWayTag("id", String.valueOf(tdWay.getId()));
assert idTag != null;
tdWay.getTags().put(idTag.getId(), OSMUtils.getObjectFromWildcardAndValue(idTag.getValue(), String.valueOf(tdWay.getId())));
} else {
// Add reference id to part element
tdWay.setRef(String.valueOf(rootId));
}
// #HDstoreData: Removing not possible, because HD' tiles need them multiple times (for count and processing)
// partRootRelations.remove(tdWay.getId());
} | [
"protected",
"void",
"addImplicitRelationInformation",
"(",
"TDWay",
"tdWay",
")",
"{",
"if",
"(",
"!",
"this",
".",
"tagValues",
")",
"{",
"return",
";",
"}",
"// FEATURE Remove this to add id to all elements (increase of space around 1/8)",
"if",
"(",
"!",
"this",
".",
"partRootRelations",
".",
"containsKey",
"(",
"tdWay",
".",
"getId",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"Long",
"rootId",
"=",
"this",
".",
"partRootRelations",
".",
"get",
"(",
"tdWay",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"rootId",
"==",
"null",
")",
"{",
"OSMTagMapping",
"mapping",
"=",
"OSMTagMapping",
".",
"getInstance",
"(",
")",
";",
"// Remove accidentally written ids in OSM",
"for",
"(",
"Short",
"aShort",
":",
"tdWay",
".",
"getTags",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"mapping",
".",
"getWayTag",
"(",
"aShort",
")",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"\"id\"",
")",
")",
"{",
"tdWay",
".",
"getTags",
"(",
")",
".",
"remove",
"(",
"aShort",
")",
";",
"break",
";",
"}",
"}",
"// Add id to root element (respecting tag-mapping file)",
"OSMTag",
"idTag",
"=",
"mapping",
".",
"getWayTag",
"(",
"\"id\"",
",",
"String",
".",
"valueOf",
"(",
"tdWay",
".",
"getId",
"(",
")",
")",
")",
";",
"assert",
"idTag",
"!=",
"null",
";",
"tdWay",
".",
"getTags",
"(",
")",
".",
"put",
"(",
"idTag",
".",
"getId",
"(",
")",
",",
"OSMUtils",
".",
"getObjectFromWildcardAndValue",
"(",
"idTag",
".",
"getValue",
"(",
")",
",",
"String",
".",
"valueOf",
"(",
"tdWay",
".",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"// Add reference id to part element",
"tdWay",
".",
"setRef",
"(",
"String",
".",
"valueOf",
"(",
"rootId",
")",
")",
";",
"}",
"// #HDstoreData: Removing not possible, because HD' tiles need them multiple times (for count and processing)",
"// partRootRelations.remove(tdWay.getId());",
"}"
] | Add tags to ways which describe the geo-inheritance.
@param tdWay the way which should get the tags | [
"Add",
"tags",
"to",
"ways",
"which",
"describe",
"the",
"geo",
"-",
"inheritance",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java#L448-L480 |
28,364 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java | BaseTileBasedDataProcessor.countPoiTags | protected void countPoiTags(TDNode poi) {
if (poi == null || poi.getTags() == null) {
return;
}
for (short tag : poi.getTags().keySet()) {
this.histogramPoiTags.adjustOrPutValue(tag, 1, 1);
}
} | java | protected void countPoiTags(TDNode poi) {
if (poi == null || poi.getTags() == null) {
return;
}
for (short tag : poi.getTags().keySet()) {
this.histogramPoiTags.adjustOrPutValue(tag, 1, 1);
}
} | [
"protected",
"void",
"countPoiTags",
"(",
"TDNode",
"poi",
")",
"{",
"if",
"(",
"poi",
"==",
"null",
"||",
"poi",
".",
"getTags",
"(",
")",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"short",
"tag",
":",
"poi",
".",
"getTags",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"this",
".",
"histogramPoiTags",
".",
"adjustOrPutValue",
"(",
"tag",
",",
"1",
",",
"1",
")",
";",
"}",
"}"
] | Count tags to optimize order of POI tag data.
@param poi the poi which contains tags | [
"Count",
"tags",
"to",
"optimize",
"order",
"of",
"POI",
"tag",
"data",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java#L536-L543 |
28,365 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java | BaseTileBasedDataProcessor.handleImplicitWayRelations | protected void handleImplicitWayRelations() {
if (!this.tagValues) {
return;
}
/*int progressImplicitRelations = 0;
float limitImplicitRelations = this.tilesToPartElements.entrySet().size();*/
// Iterate through tiles which contain parts
for (Map.Entry<TileCoordinate, TLongHashSet> tilePartElementEntry : this.tilesToPartElements.entrySet()) {
TLongHashSet tileRootElementSet = this.tilesToRootElements.get(tilePartElementEntry.getKey());
// Continue if no part or no roots are in list; maybe unnecessary
if (tileRootElementSet == null || tileRootElementSet.isEmpty()
|| tilePartElementEntry.getValue().isEmpty()) {
continue;
}
// Log
/*String wayRelLog = "Progress: Implicit relations "
+ ((int) ((progressImplicitRelations / limitImplicitRelations) * 100))
+ "%% - Tile (" + tilePartElementEntry.getKey().getX()
+ ", " + tilePartElementEntry.getKey().getY() + ")";
progressImplicitRelations++;
int nRootElements = 0;*/
// Load parts only once in cache
List<TDWay> pElems = new ArrayList<>();
TLongIterator tilePartElementIterator = tilePartElementEntry.getValue().iterator();
while (tilePartElementIterator.hasNext()) {
TDWay pElem = getWay(tilePartElementIterator.next());
pElems.add(pElem);
}
// Iterate through potential roots
TLongIterator tileRootElementIterator = tileRootElementSet.iterator();
while (tileRootElementIterator.hasNext()) {
/*if(this.progressLogs) {
if (++nRootElements % 1000 == 0) {
System.out.print((wayRelLog + " - Elements " + nfCounts.format(nRootElements) + "\r"));
}
}*/
// Init root element
TDWay rElem = getWay(tileRootElementIterator.next());
BoundingBox rBox = GeoUtils.mapWayToBoundingBox(rElem);
if (rBox == null) {
continue;
}
Polygon rPolygon = null; // Lazy initialization, because root may not be needed
// Iterate through parts
for (int i = pElems.size() - 1; i >= 0; i--) {
TDWay pElem = pElems.get(i);
// Exclude most elements with bounding box
if (pElem.getWayNodes().length < 3) {
continue;
}
if (!rBox.contains(LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLatitude()),
LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLongitude()))) {
continue;
}
// Now calculate exact polygons
Polygon pPolygon = GeoUtils.mapWayToPolygon(pElem);
if (pPolygon == null) {
continue;
}
if (rPolygon == null) {
rPolygon = GeoUtils.mapWayToPolygon(rElem);
if (rPolygon == null) {
continue;
}
}
/* Use interior point cause
* - boundary points may intersect with other geometries
* - part polygon often not completely covered by root polygon
*/
if (rPolygon.covers(pPolygon.getInteriorPoint())) {
// Memorize multi-polygons
if (!this.partRootRelations.containsKey(rElem.getId())) {
this.partRootRelations.put(rElem.getId(), null); // Add root element
}
this.partRootRelations.put(pElem.getId(), rElem.getId()); // Add part element
// Remove part which is already referenced
pElems.remove(pElem);
tilePartElementEntry.getValue().remove(pElem.getId());
}
}
}
}
LOGGER.info("calculated " + nfCounts.format(partRootRelations.size()) + " implicit relations");
} | java | protected void handleImplicitWayRelations() {
if (!this.tagValues) {
return;
}
/*int progressImplicitRelations = 0;
float limitImplicitRelations = this.tilesToPartElements.entrySet().size();*/
// Iterate through tiles which contain parts
for (Map.Entry<TileCoordinate, TLongHashSet> tilePartElementEntry : this.tilesToPartElements.entrySet()) {
TLongHashSet tileRootElementSet = this.tilesToRootElements.get(tilePartElementEntry.getKey());
// Continue if no part or no roots are in list; maybe unnecessary
if (tileRootElementSet == null || tileRootElementSet.isEmpty()
|| tilePartElementEntry.getValue().isEmpty()) {
continue;
}
// Log
/*String wayRelLog = "Progress: Implicit relations "
+ ((int) ((progressImplicitRelations / limitImplicitRelations) * 100))
+ "%% - Tile (" + tilePartElementEntry.getKey().getX()
+ ", " + tilePartElementEntry.getKey().getY() + ")";
progressImplicitRelations++;
int nRootElements = 0;*/
// Load parts only once in cache
List<TDWay> pElems = new ArrayList<>();
TLongIterator tilePartElementIterator = tilePartElementEntry.getValue().iterator();
while (tilePartElementIterator.hasNext()) {
TDWay pElem = getWay(tilePartElementIterator.next());
pElems.add(pElem);
}
// Iterate through potential roots
TLongIterator tileRootElementIterator = tileRootElementSet.iterator();
while (tileRootElementIterator.hasNext()) {
/*if(this.progressLogs) {
if (++nRootElements % 1000 == 0) {
System.out.print((wayRelLog + " - Elements " + nfCounts.format(nRootElements) + "\r"));
}
}*/
// Init root element
TDWay rElem = getWay(tileRootElementIterator.next());
BoundingBox rBox = GeoUtils.mapWayToBoundingBox(rElem);
if (rBox == null) {
continue;
}
Polygon rPolygon = null; // Lazy initialization, because root may not be needed
// Iterate through parts
for (int i = pElems.size() - 1; i >= 0; i--) {
TDWay pElem = pElems.get(i);
// Exclude most elements with bounding box
if (pElem.getWayNodes().length < 3) {
continue;
}
if (!rBox.contains(LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLatitude()),
LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLongitude()))) {
continue;
}
// Now calculate exact polygons
Polygon pPolygon = GeoUtils.mapWayToPolygon(pElem);
if (pPolygon == null) {
continue;
}
if (rPolygon == null) {
rPolygon = GeoUtils.mapWayToPolygon(rElem);
if (rPolygon == null) {
continue;
}
}
/* Use interior point cause
* - boundary points may intersect with other geometries
* - part polygon often not completely covered by root polygon
*/
if (rPolygon.covers(pPolygon.getInteriorPoint())) {
// Memorize multi-polygons
if (!this.partRootRelations.containsKey(rElem.getId())) {
this.partRootRelations.put(rElem.getId(), null); // Add root element
}
this.partRootRelations.put(pElem.getId(), rElem.getId()); // Add part element
// Remove part which is already referenced
pElems.remove(pElem);
tilePartElementEntry.getValue().remove(pElem.getId());
}
}
}
}
LOGGER.info("calculated " + nfCounts.format(partRootRelations.size()) + " implicit relations");
} | [
"protected",
"void",
"handleImplicitWayRelations",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"tagValues",
")",
"{",
"return",
";",
"}",
"/*int progressImplicitRelations = 0;\n float limitImplicitRelations = this.tilesToPartElements.entrySet().size();*/",
"// Iterate through tiles which contain parts",
"for",
"(",
"Map",
".",
"Entry",
"<",
"TileCoordinate",
",",
"TLongHashSet",
">",
"tilePartElementEntry",
":",
"this",
".",
"tilesToPartElements",
".",
"entrySet",
"(",
")",
")",
"{",
"TLongHashSet",
"tileRootElementSet",
"=",
"this",
".",
"tilesToRootElements",
".",
"get",
"(",
"tilePartElementEntry",
".",
"getKey",
"(",
")",
")",
";",
"// Continue if no part or no roots are in list; maybe unnecessary",
"if",
"(",
"tileRootElementSet",
"==",
"null",
"||",
"tileRootElementSet",
".",
"isEmpty",
"(",
")",
"||",
"tilePartElementEntry",
".",
"getValue",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"// Log",
"/*String wayRelLog = \"Progress: Implicit relations \"\n + ((int) ((progressImplicitRelations / limitImplicitRelations) * 100))\n + \"%% - Tile (\" + tilePartElementEntry.getKey().getX()\n + \", \" + tilePartElementEntry.getKey().getY() + \")\";\n progressImplicitRelations++;\n int nRootElements = 0;*/",
"// Load parts only once in cache",
"List",
"<",
"TDWay",
">",
"pElems",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"TLongIterator",
"tilePartElementIterator",
"=",
"tilePartElementEntry",
".",
"getValue",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"tilePartElementIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"TDWay",
"pElem",
"=",
"getWay",
"(",
"tilePartElementIterator",
".",
"next",
"(",
")",
")",
";",
"pElems",
".",
"add",
"(",
"pElem",
")",
";",
"}",
"// Iterate through potential roots",
"TLongIterator",
"tileRootElementIterator",
"=",
"tileRootElementSet",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"tileRootElementIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"/*if(this.progressLogs) {\n if (++nRootElements % 1000 == 0) {\n System.out.print((wayRelLog + \" - Elements \" + nfCounts.format(nRootElements) + \"\\r\"));\n }\n }*/",
"// Init root element",
"TDWay",
"rElem",
"=",
"getWay",
"(",
"tileRootElementIterator",
".",
"next",
"(",
")",
")",
";",
"BoundingBox",
"rBox",
"=",
"GeoUtils",
".",
"mapWayToBoundingBox",
"(",
"rElem",
")",
";",
"if",
"(",
"rBox",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"Polygon",
"rPolygon",
"=",
"null",
";",
"// Lazy initialization, because root may not be needed",
"// Iterate through parts",
"for",
"(",
"int",
"i",
"=",
"pElems",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"TDWay",
"pElem",
"=",
"pElems",
".",
"get",
"(",
"i",
")",
";",
"// Exclude most elements with bounding box",
"if",
"(",
"pElem",
".",
"getWayNodes",
"(",
")",
".",
"length",
"<",
"3",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"rBox",
".",
"contains",
"(",
"LatLongUtils",
".",
"microdegreesToDegrees",
"(",
"pElem",
".",
"getWayNodes",
"(",
")",
"[",
"0",
"]",
".",
"getLatitude",
"(",
")",
")",
",",
"LatLongUtils",
".",
"microdegreesToDegrees",
"(",
"pElem",
".",
"getWayNodes",
"(",
")",
"[",
"0",
"]",
".",
"getLongitude",
"(",
")",
")",
")",
")",
"{",
"continue",
";",
"}",
"// Now calculate exact polygons",
"Polygon",
"pPolygon",
"=",
"GeoUtils",
".",
"mapWayToPolygon",
"(",
"pElem",
")",
";",
"if",
"(",
"pPolygon",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"rPolygon",
"==",
"null",
")",
"{",
"rPolygon",
"=",
"GeoUtils",
".",
"mapWayToPolygon",
"(",
"rElem",
")",
";",
"if",
"(",
"rPolygon",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"}",
"/* Use interior point cause\n * - boundary points may intersect with other geometries\n * - part polygon often not completely covered by root polygon\n */",
"if",
"(",
"rPolygon",
".",
"covers",
"(",
"pPolygon",
".",
"getInteriorPoint",
"(",
")",
")",
")",
"{",
"// Memorize multi-polygons",
"if",
"(",
"!",
"this",
".",
"partRootRelations",
".",
"containsKey",
"(",
"rElem",
".",
"getId",
"(",
")",
")",
")",
"{",
"this",
".",
"partRootRelations",
".",
"put",
"(",
"rElem",
".",
"getId",
"(",
")",
",",
"null",
")",
";",
"// Add root element",
"}",
"this",
".",
"partRootRelations",
".",
"put",
"(",
"pElem",
".",
"getId",
"(",
")",
",",
"rElem",
".",
"getId",
"(",
")",
")",
";",
"// Add part element",
"// Remove part which is already referenced",
"pElems",
".",
"remove",
"(",
"pElem",
")",
";",
"tilePartElementEntry",
".",
"getValue",
"(",
")",
".",
"remove",
"(",
"pElem",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"LOGGER",
".",
"info",
"(",
"\"calculated \"",
"+",
"nfCounts",
".",
"format",
"(",
"partRootRelations",
".",
"size",
"(",
")",
")",
"+",
"\" implicit relations\"",
")",
";",
"}"
] | Calculate ids of ways whose polygon inherits part elements. | [
"Calculate",
"ids",
"of",
"ways",
"whose",
"polygon",
"inherits",
"part",
"elements",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/BaseTileBasedDataProcessor.java#L571-L667 |
28,366 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/WayDecorator.java | WayDecorator.renderText | static void renderText(GraphicFactory graphicFactory, Tile upperLeft, Tile lowerRight, String text, Display display, int priority, float dy,
Paint fill, Paint stroke,
boolean repeat, float repeatGap, float repeatStart, boolean rotate, Point[][] coordinates,
List<MapElementContainer> currentLabels) {
if (coordinates.length == 0) {
return;
}
Point[] c;
if (dy == 0f) {
c = coordinates[0];
} else {
c = RendererUtils.parallelPath(coordinates[0], dy);
}
if (c.length < 2) {
return;
}
LineString path = new LineString();
for (int i = 1; i < c.length; i++) {
LineSegment segment = new LineSegment(c[i - 1], c[i]);
path.segments.add(segment);
}
int textWidth = (stroke == null) ? fill.getTextWidth(text) : stroke.getTextWidth(text);
int textHeight = (stroke == null) ? fill.getTextHeight(text) : stroke.getTextHeight(text);
double pathLength = path.length();
for (float pos = repeatStart; pos + textWidth < pathLength; pos += repeatGap + textWidth) {
LineString linePart = path.extractPart(pos, pos + textWidth);
boolean tooSharp = false;
for (int i = 1; i < linePart.segments.size(); i++) {
double cornerAngle = linePart.segments.get(i - 1).angleTo(linePart.segments.get(i));
if (Math.abs(cornerAngle) > MAX_LABEL_CORNER_ANGLE) {
tooSharp = true;
break;
}
}
if (tooSharp)
continue;
currentLabels.add(new WayTextContainer(graphicFactory, linePart, display, priority, text, fill, stroke, textHeight));
}
} | java | static void renderText(GraphicFactory graphicFactory, Tile upperLeft, Tile lowerRight, String text, Display display, int priority, float dy,
Paint fill, Paint stroke,
boolean repeat, float repeatGap, float repeatStart, boolean rotate, Point[][] coordinates,
List<MapElementContainer> currentLabels) {
if (coordinates.length == 0) {
return;
}
Point[] c;
if (dy == 0f) {
c = coordinates[0];
} else {
c = RendererUtils.parallelPath(coordinates[0], dy);
}
if (c.length < 2) {
return;
}
LineString path = new LineString();
for (int i = 1; i < c.length; i++) {
LineSegment segment = new LineSegment(c[i - 1], c[i]);
path.segments.add(segment);
}
int textWidth = (stroke == null) ? fill.getTextWidth(text) : stroke.getTextWidth(text);
int textHeight = (stroke == null) ? fill.getTextHeight(text) : stroke.getTextHeight(text);
double pathLength = path.length();
for (float pos = repeatStart; pos + textWidth < pathLength; pos += repeatGap + textWidth) {
LineString linePart = path.extractPart(pos, pos + textWidth);
boolean tooSharp = false;
for (int i = 1; i < linePart.segments.size(); i++) {
double cornerAngle = linePart.segments.get(i - 1).angleTo(linePart.segments.get(i));
if (Math.abs(cornerAngle) > MAX_LABEL_CORNER_ANGLE) {
tooSharp = true;
break;
}
}
if (tooSharp)
continue;
currentLabels.add(new WayTextContainer(graphicFactory, linePart, display, priority, text, fill, stroke, textHeight));
}
} | [
"static",
"void",
"renderText",
"(",
"GraphicFactory",
"graphicFactory",
",",
"Tile",
"upperLeft",
",",
"Tile",
"lowerRight",
",",
"String",
"text",
",",
"Display",
"display",
",",
"int",
"priority",
",",
"float",
"dy",
",",
"Paint",
"fill",
",",
"Paint",
"stroke",
",",
"boolean",
"repeat",
",",
"float",
"repeatGap",
",",
"float",
"repeatStart",
",",
"boolean",
"rotate",
",",
"Point",
"[",
"]",
"[",
"]",
"coordinates",
",",
"List",
"<",
"MapElementContainer",
">",
"currentLabels",
")",
"{",
"if",
"(",
"coordinates",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"Point",
"[",
"]",
"c",
";",
"if",
"(",
"dy",
"==",
"0f",
")",
"{",
"c",
"=",
"coordinates",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"c",
"=",
"RendererUtils",
".",
"parallelPath",
"(",
"coordinates",
"[",
"0",
"]",
",",
"dy",
")",
";",
"}",
"if",
"(",
"c",
".",
"length",
"<",
"2",
")",
"{",
"return",
";",
"}",
"LineString",
"path",
"=",
"new",
"LineString",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"c",
".",
"length",
";",
"i",
"++",
")",
"{",
"LineSegment",
"segment",
"=",
"new",
"LineSegment",
"(",
"c",
"[",
"i",
"-",
"1",
"]",
",",
"c",
"[",
"i",
"]",
")",
";",
"path",
".",
"segments",
".",
"add",
"(",
"segment",
")",
";",
"}",
"int",
"textWidth",
"=",
"(",
"stroke",
"==",
"null",
")",
"?",
"fill",
".",
"getTextWidth",
"(",
"text",
")",
":",
"stroke",
".",
"getTextWidth",
"(",
"text",
")",
";",
"int",
"textHeight",
"=",
"(",
"stroke",
"==",
"null",
")",
"?",
"fill",
".",
"getTextHeight",
"(",
"text",
")",
":",
"stroke",
".",
"getTextHeight",
"(",
"text",
")",
";",
"double",
"pathLength",
"=",
"path",
".",
"length",
"(",
")",
";",
"for",
"(",
"float",
"pos",
"=",
"repeatStart",
";",
"pos",
"+",
"textWidth",
"<",
"pathLength",
";",
"pos",
"+=",
"repeatGap",
"+",
"textWidth",
")",
"{",
"LineString",
"linePart",
"=",
"path",
".",
"extractPart",
"(",
"pos",
",",
"pos",
"+",
"textWidth",
")",
";",
"boolean",
"tooSharp",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"linePart",
".",
"segments",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"cornerAngle",
"=",
"linePart",
".",
"segments",
".",
"get",
"(",
"i",
"-",
"1",
")",
".",
"angleTo",
"(",
"linePart",
".",
"segments",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"cornerAngle",
")",
">",
"MAX_LABEL_CORNER_ANGLE",
")",
"{",
"tooSharp",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"tooSharp",
")",
"continue",
";",
"currentLabels",
".",
"add",
"(",
"new",
"WayTextContainer",
"(",
"graphicFactory",
",",
"linePart",
",",
"display",
",",
"priority",
",",
"text",
",",
"fill",
",",
"stroke",
",",
"textHeight",
")",
")",
";",
"}",
"}"
] | Finds the segments of a line along which a name can be drawn and then adds WayTextContainers
to the list of drawable items.
@param upperLeft the tile in the upper left corner of the drawing pane
@param lowerRight the tile in the lower right corner of the drawing pane
@param text the text to draw
@param priority priority of the text
@param dy if 0, then a line parallel to the coordinates will be calculated first
@param fill fill paint for text
@param stroke stroke paint for text
@param coordinates the list of way coordinates
@param currentLabels the list of labels to which a new WayTextContainer will be added | [
"Finds",
"the",
"segments",
"of",
"a",
"line",
"along",
"which",
"a",
"name",
"can",
"be",
"drawn",
"and",
"then",
"adds",
"WayTextContainers",
"to",
"the",
"list",
"of",
"drawable",
"items",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/WayDecorator.java#L127-L173 |
28,367 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.writeExceptionToParcel | public static final void writeExceptionToParcel(Parcel reply, Exception e) {
int code = 0;
boolean logException = true;
if (e instanceof FileNotFoundException) {
code = 1;
logException = false;
} else if (e instanceof IllegalArgumentException) {
code = 2;
} else if (e instanceof UnsupportedOperationException) {
code = 3;
} else if (e instanceof SQLiteAbortException) {
code = 4;
} else if (e instanceof SQLiteConstraintException) {
code = 5;
} else if (e instanceof SQLiteDatabaseCorruptException) {
code = 6;
} else if (e instanceof SQLiteFullException) {
code = 7;
} else if (e instanceof SQLiteDiskIOException) {
code = 8;
} else if (e instanceof SQLiteException) {
code = 9;
} else if (e instanceof OperationApplicationException) {
code = 10;
} else if (e instanceof OperationCanceledException) {
code = 11;
logException = false;
} else {
reply.writeException(e);
Log.e(TAG, "Writing exception to parcel", e);
return;
}
reply.writeInt(code);
reply.writeString(e.getMessage());
if (logException) {
Log.e(TAG, "Writing exception to parcel", e);
}
} | java | public static final void writeExceptionToParcel(Parcel reply, Exception e) {
int code = 0;
boolean logException = true;
if (e instanceof FileNotFoundException) {
code = 1;
logException = false;
} else if (e instanceof IllegalArgumentException) {
code = 2;
} else if (e instanceof UnsupportedOperationException) {
code = 3;
} else if (e instanceof SQLiteAbortException) {
code = 4;
} else if (e instanceof SQLiteConstraintException) {
code = 5;
} else if (e instanceof SQLiteDatabaseCorruptException) {
code = 6;
} else if (e instanceof SQLiteFullException) {
code = 7;
} else if (e instanceof SQLiteDiskIOException) {
code = 8;
} else if (e instanceof SQLiteException) {
code = 9;
} else if (e instanceof OperationApplicationException) {
code = 10;
} else if (e instanceof OperationCanceledException) {
code = 11;
logException = false;
} else {
reply.writeException(e);
Log.e(TAG, "Writing exception to parcel", e);
return;
}
reply.writeInt(code);
reply.writeString(e.getMessage());
if (logException) {
Log.e(TAG, "Writing exception to parcel", e);
}
} | [
"public",
"static",
"final",
"void",
"writeExceptionToParcel",
"(",
"Parcel",
"reply",
",",
"Exception",
"e",
")",
"{",
"int",
"code",
"=",
"0",
";",
"boolean",
"logException",
"=",
"true",
";",
"if",
"(",
"e",
"instanceof",
"FileNotFoundException",
")",
"{",
"code",
"=",
"1",
";",
"logException",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"IllegalArgumentException",
")",
"{",
"code",
"=",
"2",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"UnsupportedOperationException",
")",
"{",
"code",
"=",
"3",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteAbortException",
")",
"{",
"code",
"=",
"4",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteConstraintException",
")",
"{",
"code",
"=",
"5",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteDatabaseCorruptException",
")",
"{",
"code",
"=",
"6",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteFullException",
")",
"{",
"code",
"=",
"7",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteDiskIOException",
")",
"{",
"code",
"=",
"8",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"SQLiteException",
")",
"{",
"code",
"=",
"9",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"OperationApplicationException",
")",
"{",
"code",
"=",
"10",
";",
"}",
"else",
"if",
"(",
"e",
"instanceof",
"OperationCanceledException",
")",
"{",
"code",
"=",
"11",
";",
"logException",
"=",
"false",
";",
"}",
"else",
"{",
"reply",
".",
"writeException",
"(",
"e",
")",
";",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Writing exception to parcel\"",
",",
"e",
")",
";",
"return",
";",
"}",
"reply",
".",
"writeInt",
"(",
"code",
")",
";",
"reply",
".",
"writeString",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"logException",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Writing exception to parcel\"",
",",
"e",
")",
";",
"}",
"}"
] | Special function for writing an exception result at the header of
a parcel, to be used when returning an exception from a transaction.
exception will be re-thrown by the function in another process
@param reply Parcel to write to
@param e The Exception to be written.
@see Parcel#writeNoException
@see Parcel#writeException | [
"Special",
"function",
"for",
"writing",
"an",
"exception",
"result",
"at",
"the",
"header",
"of",
"a",
"parcel",
"to",
"be",
"used",
"when",
"returning",
"an",
"exception",
"from",
"a",
"transaction",
".",
"exception",
"will",
"be",
"re",
"-",
"thrown",
"by",
"the",
"function",
"in",
"another",
"process"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L87-L125 |
28,368 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorFillWindow | public static void cursorFillWindow(final Cursor cursor,
int position, final CursorWindow window) {
if (position < 0 || position >= cursor.getCount()) {
return;
}
final int oldPos = cursor.getPosition();
final int numColumns = cursor.getColumnCount();
window.clear();
window.setStartPosition(position);
window.setNumColumns(numColumns);
if (cursor.moveToPosition(position)) {
rowloop: do {
if (!window.allocRow()) {
break;
}
for (int i = 0; i < numColumns; i++) {
final int type = cursor.getType(i);
final boolean success;
switch (type) {
case Cursor.FIELD_TYPE_NULL:
success = window.putNull(position, i);
break;
case Cursor.FIELD_TYPE_INTEGER:
success = window.putLong(cursor.getLong(i), position, i);
break;
case Cursor.FIELD_TYPE_FLOAT:
success = window.putDouble(cursor.getDouble(i), position, i);
break;
case Cursor.FIELD_TYPE_BLOB: {
final byte[] value = cursor.getBlob(i);
success = value != null ? window.putBlob(value, position, i)
: window.putNull(position, i);
break;
}
default: // assume value is convertible to String
case Cursor.FIELD_TYPE_STRING: {
final String value = cursor.getString(i);
success = value != null ? window.putString(value, position, i)
: window.putNull(position, i);
break;
}
}
if (!success) {
window.freeLastRow();
break rowloop;
}
}
position += 1;
} while (cursor.moveToNext());
}
cursor.moveToPosition(oldPos);
} | java | public static void cursorFillWindow(final Cursor cursor,
int position, final CursorWindow window) {
if (position < 0 || position >= cursor.getCount()) {
return;
}
final int oldPos = cursor.getPosition();
final int numColumns = cursor.getColumnCount();
window.clear();
window.setStartPosition(position);
window.setNumColumns(numColumns);
if (cursor.moveToPosition(position)) {
rowloop: do {
if (!window.allocRow()) {
break;
}
for (int i = 0; i < numColumns; i++) {
final int type = cursor.getType(i);
final boolean success;
switch (type) {
case Cursor.FIELD_TYPE_NULL:
success = window.putNull(position, i);
break;
case Cursor.FIELD_TYPE_INTEGER:
success = window.putLong(cursor.getLong(i), position, i);
break;
case Cursor.FIELD_TYPE_FLOAT:
success = window.putDouble(cursor.getDouble(i), position, i);
break;
case Cursor.FIELD_TYPE_BLOB: {
final byte[] value = cursor.getBlob(i);
success = value != null ? window.putBlob(value, position, i)
: window.putNull(position, i);
break;
}
default: // assume value is convertible to String
case Cursor.FIELD_TYPE_STRING: {
final String value = cursor.getString(i);
success = value != null ? window.putString(value, position, i)
: window.putNull(position, i);
break;
}
}
if (!success) {
window.freeLastRow();
break rowloop;
}
}
position += 1;
} while (cursor.moveToNext());
}
cursor.moveToPosition(oldPos);
} | [
"public",
"static",
"void",
"cursorFillWindow",
"(",
"final",
"Cursor",
"cursor",
",",
"int",
"position",
",",
"final",
"CursorWindow",
"window",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"cursor",
".",
"getCount",
"(",
")",
")",
"{",
"return",
";",
"}",
"final",
"int",
"oldPos",
"=",
"cursor",
".",
"getPosition",
"(",
")",
";",
"final",
"int",
"numColumns",
"=",
"cursor",
".",
"getColumnCount",
"(",
")",
";",
"window",
".",
"clear",
"(",
")",
";",
"window",
".",
"setStartPosition",
"(",
"position",
")",
";",
"window",
".",
"setNumColumns",
"(",
"numColumns",
")",
";",
"if",
"(",
"cursor",
".",
"moveToPosition",
"(",
"position",
")",
")",
"{",
"rowloop",
":",
"do",
"{",
"if",
"(",
"!",
"window",
".",
"allocRow",
"(",
")",
")",
"{",
"break",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numColumns",
";",
"i",
"++",
")",
"{",
"final",
"int",
"type",
"=",
"cursor",
".",
"getType",
"(",
"i",
")",
";",
"final",
"boolean",
"success",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"Cursor",
".",
"FIELD_TYPE_NULL",
":",
"success",
"=",
"window",
".",
"putNull",
"(",
"position",
",",
"i",
")",
";",
"break",
";",
"case",
"Cursor",
".",
"FIELD_TYPE_INTEGER",
":",
"success",
"=",
"window",
".",
"putLong",
"(",
"cursor",
".",
"getLong",
"(",
"i",
")",
",",
"position",
",",
"i",
")",
";",
"break",
";",
"case",
"Cursor",
".",
"FIELD_TYPE_FLOAT",
":",
"success",
"=",
"window",
".",
"putDouble",
"(",
"cursor",
".",
"getDouble",
"(",
"i",
")",
",",
"position",
",",
"i",
")",
";",
"break",
";",
"case",
"Cursor",
".",
"FIELD_TYPE_BLOB",
":",
"{",
"final",
"byte",
"[",
"]",
"value",
"=",
"cursor",
".",
"getBlob",
"(",
"i",
")",
";",
"success",
"=",
"value",
"!=",
"null",
"?",
"window",
".",
"putBlob",
"(",
"value",
",",
"position",
",",
"i",
")",
":",
"window",
".",
"putNull",
"(",
"position",
",",
"i",
")",
";",
"break",
";",
"}",
"default",
":",
"// assume value is convertible to String",
"case",
"Cursor",
".",
"FIELD_TYPE_STRING",
":",
"{",
"final",
"String",
"value",
"=",
"cursor",
".",
"getString",
"(",
"i",
")",
";",
"success",
"=",
"value",
"!=",
"null",
"?",
"window",
".",
"putString",
"(",
"value",
",",
"position",
",",
"i",
")",
":",
"window",
".",
"putNull",
"(",
"position",
",",
"i",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"success",
")",
"{",
"window",
".",
"freeLastRow",
"(",
")",
";",
"break",
"rowloop",
";",
"}",
"}",
"position",
"+=",
"1",
";",
"}",
"while",
"(",
"cursor",
".",
"moveToNext",
"(",
")",
")",
";",
"}",
"cursor",
".",
"moveToPosition",
"(",
"oldPos",
")",
";",
"}"
] | Fills the specified cursor window by iterating over the contents of the cursor.
The window is filled until the cursor is exhausted or the window runs out
of space.
The original position of the cursor is left unchanged by this operation.
@param cursor The cursor that contains the data to put in the window.
@param position The start position for filling the window.
@param window The window to fill.
@hide | [
"Fills",
"the",
"specified",
"cursor",
"window",
"by",
"iterating",
"over",
"the",
"contents",
"of",
"the",
"cursor",
".",
"The",
"window",
"is",
"filled",
"until",
"the",
"cursor",
"is",
"exhausted",
"or",
"the",
"window",
"runs",
"out",
"of",
"space",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L267-L322 |
28,369 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.appendEscapedSQLString | public static void appendEscapedSQLString(StringBuilder sb, String sqlString) {
sb.append('\'');
if (sqlString.indexOf('\'') != -1) {
int length = sqlString.length();
for (int i = 0; i < length; i++) {
char c = sqlString.charAt(i);
if (c == '\'') {
sb.append('\'');
}
sb.append(c);
}
} else
sb.append(sqlString);
sb.append('\'');
} | java | public static void appendEscapedSQLString(StringBuilder sb, String sqlString) {
sb.append('\'');
if (sqlString.indexOf('\'') != -1) {
int length = sqlString.length();
for (int i = 0; i < length; i++) {
char c = sqlString.charAt(i);
if (c == '\'') {
sb.append('\'');
}
sb.append(c);
}
} else
sb.append(sqlString);
sb.append('\'');
} | [
"public",
"static",
"void",
"appendEscapedSQLString",
"(",
"StringBuilder",
"sb",
",",
"String",
"sqlString",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"if",
"(",
"sqlString",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"{",
"int",
"length",
"=",
"sqlString",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"sqlString",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"else",
"sb",
".",
"append",
"(",
"sqlString",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] | Appends an SQL string to the given StringBuilder, including the opening
and closing single quotes. Any single quotes internal to sqlString will
be escaped.
This method is deprecated because we want to encourage everyone
to use the "?" binding form. However, when implementing a
ContentProvider, one may want to add WHERE clauses that were
not provided by the caller. Since "?" is a positional form,
using it in this case could break the caller because the
indexes would be shifted to accomodate the ContentProvider's
internal bindings. In that case, it may be necessary to
construct a WHERE clause manually. This method is useful for
those cases.
@param sb the StringBuilder that the SQL string will be appended to
@param sqlString the raw string to be appended, which may contain single
quotes | [
"Appends",
"an",
"SQL",
"string",
"to",
"the",
"given",
"StringBuilder",
"including",
"the",
"opening",
"and",
"closing",
"single",
"quotes",
".",
"Any",
"single",
"quotes",
"internal",
"to",
"sqlString",
"will",
"be",
"escaped",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L343-L357 |
28,370 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.sqlEscapeString | public static String sqlEscapeString(String value) {
StringBuilder escaper = new StringBuilder();
DatabaseUtils.appendEscapedSQLString(escaper, value);
return escaper.toString();
} | java | public static String sqlEscapeString(String value) {
StringBuilder escaper = new StringBuilder();
DatabaseUtils.appendEscapedSQLString(escaper, value);
return escaper.toString();
} | [
"public",
"static",
"String",
"sqlEscapeString",
"(",
"String",
"value",
")",
"{",
"StringBuilder",
"escaper",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"DatabaseUtils",
".",
"appendEscapedSQLString",
"(",
"escaper",
",",
"value",
")",
";",
"return",
"escaper",
".",
"toString",
"(",
")",
";",
"}"
] | SQL-escape a string. | [
"SQL",
"-",
"escape",
"a",
"string",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L362-L368 |
28,371 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.appendValueToSql | public static final void appendValueToSql(StringBuilder sql, Object value) {
if (value == null) {
sql.append("NULL");
} else if (value instanceof Boolean) {
Boolean bool = (Boolean)value;
if (bool) {
sql.append('1');
} else {
sql.append('0');
}
} else {
appendEscapedSQLString(sql, value.toString());
}
} | java | public static final void appendValueToSql(StringBuilder sql, Object value) {
if (value == null) {
sql.append("NULL");
} else if (value instanceof Boolean) {
Boolean bool = (Boolean)value;
if (bool) {
sql.append('1');
} else {
sql.append('0');
}
} else {
appendEscapedSQLString(sql, value.toString());
}
} | [
"public",
"static",
"final",
"void",
"appendValueToSql",
"(",
"StringBuilder",
"sql",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"sql",
".",
"append",
"(",
"\"NULL\"",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"Boolean",
"bool",
"=",
"(",
"Boolean",
")",
"value",
";",
"if",
"(",
"bool",
")",
"{",
"sql",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"sql",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"else",
"{",
"appendEscapedSQLString",
"(",
"sql",
",",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Appends an Object to an SQL string with the proper escaping, etc. | [
"Appends",
"an",
"Object",
"to",
"an",
"SQL",
"string",
"with",
"the",
"proper",
"escaping",
"etc",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L373-L386 |
28,372 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.concatenateWhere | public static String concatenateWhere(String a, String b) {
if (TextUtils.isEmpty(a)) {
return b;
}
if (TextUtils.isEmpty(b)) {
return a;
}
return "(" + a + ") AND (" + b + ")";
} | java | public static String concatenateWhere(String a, String b) {
if (TextUtils.isEmpty(a)) {
return b;
}
if (TextUtils.isEmpty(b)) {
return a;
}
return "(" + a + ") AND (" + b + ")";
} | [
"public",
"static",
"String",
"concatenateWhere",
"(",
"String",
"a",
",",
"String",
"b",
")",
"{",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"a",
")",
")",
"{",
"return",
"b",
";",
"}",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"b",
")",
")",
"{",
"return",
"a",
";",
"}",
"return",
"\"(\"",
"+",
"a",
"+",
"\") AND (\"",
"+",
"b",
"+",
"\")\"",
";",
"}"
] | Concatenates two SQL WHERE clauses, handling empty or null values. | [
"Concatenates",
"two",
"SQL",
"WHERE",
"clauses",
"handling",
"empty",
"or",
"null",
"values",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L391-L400 |
28,373 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.getCollationKey | public static String getCollationKey(String name) {
byte [] arr = getCollationKeyInBytes(name);
try {
return new String(arr, 0, getKeyLen(arr), "ISO8859_1");
} catch (Exception ex) {
return "";
}
} | java | public static String getCollationKey(String name) {
byte [] arr = getCollationKeyInBytes(name);
try {
return new String(arr, 0, getKeyLen(arr), "ISO8859_1");
} catch (Exception ex) {
return "";
}
} | [
"public",
"static",
"String",
"getCollationKey",
"(",
"String",
"name",
")",
"{",
"byte",
"[",
"]",
"arr",
"=",
"getCollationKeyInBytes",
"(",
"name",
")",
";",
"try",
"{",
"return",
"new",
"String",
"(",
"arr",
",",
"0",
",",
"getKeyLen",
"(",
"arr",
")",
",",
"\"ISO8859_1\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | return the collation key
@param name
@return the collation key | [
"return",
"the",
"collation",
"key"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L407-L414 |
28,374 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.getHexCollationKey | public static String getHexCollationKey(String name) {
byte[] arr = getCollationKeyInBytes(name);
char[] keys = encodeHex(arr);
return new String(keys, 0, getKeyLen(arr) * 2);
} | java | public static String getHexCollationKey(String name) {
byte[] arr = getCollationKeyInBytes(name);
char[] keys = encodeHex(arr);
return new String(keys, 0, getKeyLen(arr) * 2);
} | [
"public",
"static",
"String",
"getHexCollationKey",
"(",
"String",
"name",
")",
"{",
"byte",
"[",
"]",
"arr",
"=",
"getCollationKeyInBytes",
"(",
"name",
")",
";",
"char",
"[",
"]",
"keys",
"=",
"encodeHex",
"(",
"arr",
")",
";",
"return",
"new",
"String",
"(",
"keys",
",",
"0",
",",
"getKeyLen",
"(",
"arr",
")",
"*",
"2",
")",
";",
"}"
] | return the collation key in hex format
@param name
@return the collation key in hex format | [
"return",
"the",
"collation",
"key",
"in",
"hex",
"format"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L421-L425 |
28,375 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCursor | public static void dumpCursor(Cursor cursor, PrintStream stream) {
stream.println(">>>>> Dumping cursor " + cursor);
if (cursor != null) {
int startPos = cursor.getPosition();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
dumpCurrentRow(cursor, stream);
}
cursor.moveToPosition(startPos);
}
stream.println("<<<<<");
} | java | public static void dumpCursor(Cursor cursor, PrintStream stream) {
stream.println(">>>>> Dumping cursor " + cursor);
if (cursor != null) {
int startPos = cursor.getPosition();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
dumpCurrentRow(cursor, stream);
}
cursor.moveToPosition(startPos);
}
stream.println("<<<<<");
} | [
"public",
"static",
"void",
"dumpCursor",
"(",
"Cursor",
"cursor",
",",
"PrintStream",
"stream",
")",
"{",
"stream",
".",
"println",
"(",
"\">>>>> Dumping cursor \"",
"+",
"cursor",
")",
";",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"int",
"startPos",
"=",
"cursor",
".",
"getPosition",
"(",
")",
";",
"cursor",
".",
"moveToPosition",
"(",
"-",
"1",
")",
";",
"while",
"(",
"cursor",
".",
"moveToNext",
"(",
")",
")",
"{",
"dumpCurrentRow",
"(",
"cursor",
",",
"stream",
")",
";",
"}",
"cursor",
".",
"moveToPosition",
"(",
"startPos",
")",
";",
"}",
"stream",
".",
"println",
"(",
"\"<<<<<\"",
")",
";",
"}"
] | Prints the contents of a Cursor to a PrintSteam. The position is restored
after printing.
@param cursor the cursor to print
@param stream the stream to print to | [
"Prints",
"the",
"contents",
"of",
"a",
"Cursor",
"to",
"a",
"PrintSteam",
".",
"The",
"position",
"is",
"restored",
"after",
"printing",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L484-L496 |
28,376 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCursor | public static void dumpCursor(Cursor cursor, StringBuilder sb) {
sb.append(">>>>> Dumping cursor " + cursor + "\n");
if (cursor != null) {
int startPos = cursor.getPosition();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
dumpCurrentRow(cursor, sb);
}
cursor.moveToPosition(startPos);
}
sb.append("<<<<<\n");
} | java | public static void dumpCursor(Cursor cursor, StringBuilder sb) {
sb.append(">>>>> Dumping cursor " + cursor + "\n");
if (cursor != null) {
int startPos = cursor.getPosition();
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
dumpCurrentRow(cursor, sb);
}
cursor.moveToPosition(startPos);
}
sb.append("<<<<<\n");
} | [
"public",
"static",
"void",
"dumpCursor",
"(",
"Cursor",
"cursor",
",",
"StringBuilder",
"sb",
")",
"{",
"sb",
".",
"append",
"(",
"\">>>>> Dumping cursor \"",
"+",
"cursor",
"+",
"\"\\n\"",
")",
";",
"if",
"(",
"cursor",
"!=",
"null",
")",
"{",
"int",
"startPos",
"=",
"cursor",
".",
"getPosition",
"(",
")",
";",
"cursor",
".",
"moveToPosition",
"(",
"-",
"1",
")",
";",
"while",
"(",
"cursor",
".",
"moveToNext",
"(",
")",
")",
"{",
"dumpCurrentRow",
"(",
"cursor",
",",
"sb",
")",
";",
"}",
"cursor",
".",
"moveToPosition",
"(",
"startPos",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"<<<<<\\n\"",
")",
";",
"}"
] | Prints the contents of a Cursor to a StringBuilder. The position
is restored after printing.
@param cursor the cursor to print
@param sb the StringBuilder to print to | [
"Prints",
"the",
"contents",
"of",
"a",
"Cursor",
"to",
"a",
"StringBuilder",
".",
"The",
"position",
"is",
"restored",
"after",
"printing",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L505-L517 |
28,377 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCursorToString | public static String dumpCursorToString(Cursor cursor) {
StringBuilder sb = new StringBuilder();
dumpCursor(cursor, sb);
return sb.toString();
} | java | public static String dumpCursorToString(Cursor cursor) {
StringBuilder sb = new StringBuilder();
dumpCursor(cursor, sb);
return sb.toString();
} | [
"public",
"static",
"String",
"dumpCursorToString",
"(",
"Cursor",
"cursor",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"dumpCursor",
"(",
"cursor",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Prints the contents of a Cursor to a String. The position is restored
after printing.
@param cursor the cursor to print
@return a String that contains the dumped cursor | [
"Prints",
"the",
"contents",
"of",
"a",
"Cursor",
"to",
"a",
"String",
".",
"The",
"position",
"is",
"restored",
"after",
"printing",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L526-L530 |
28,378 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCurrentRow | public static void dumpCurrentRow(Cursor cursor, PrintStream stream) {
String[] cols = cursor.getColumnNames();
stream.println("" + cursor.getPosition() + " {");
int length = cols.length;
for (int i = 0; i< length; i++) {
String value;
try {
value = cursor.getString(i);
} catch (SQLiteException e) {
// assume that if the getString threw this exception then the column is not
// representable by a string, e.g. it is a BLOB.
value = "<unprintable>";
}
stream.println(" " + cols[i] + '=' + value);
}
stream.println("}");
} | java | public static void dumpCurrentRow(Cursor cursor, PrintStream stream) {
String[] cols = cursor.getColumnNames();
stream.println("" + cursor.getPosition() + " {");
int length = cols.length;
for (int i = 0; i< length; i++) {
String value;
try {
value = cursor.getString(i);
} catch (SQLiteException e) {
// assume that if the getString threw this exception then the column is not
// representable by a string, e.g. it is a BLOB.
value = "<unprintable>";
}
stream.println(" " + cols[i] + '=' + value);
}
stream.println("}");
} | [
"public",
"static",
"void",
"dumpCurrentRow",
"(",
"Cursor",
"cursor",
",",
"PrintStream",
"stream",
")",
"{",
"String",
"[",
"]",
"cols",
"=",
"cursor",
".",
"getColumnNames",
"(",
")",
";",
"stream",
".",
"println",
"(",
"\"\"",
"+",
"cursor",
".",
"getPosition",
"(",
")",
"+",
"\" {\"",
")",
";",
"int",
"length",
"=",
"cols",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"String",
"value",
";",
"try",
"{",
"value",
"=",
"cursor",
".",
"getString",
"(",
"i",
")",
";",
"}",
"catch",
"(",
"SQLiteException",
"e",
")",
"{",
"// assume that if the getString threw this exception then the column is not",
"// representable by a string, e.g. it is a BLOB.",
"value",
"=",
"\"<unprintable>\"",
";",
"}",
"stream",
".",
"println",
"(",
"\" \"",
"+",
"cols",
"[",
"i",
"]",
"+",
"'",
"'",
"+",
"value",
")",
";",
"}",
"stream",
".",
"println",
"(",
"\"}\"",
")",
";",
"}"
] | Prints the contents of a Cursor's current row to a PrintSteam.
@param cursor the cursor to print
@param stream the stream to print to | [
"Prints",
"the",
"contents",
"of",
"a",
"Cursor",
"s",
"current",
"row",
"to",
"a",
"PrintSteam",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L547-L563 |
28,379 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCurrentRow | public static void dumpCurrentRow(Cursor cursor, StringBuilder sb) {
String[] cols = cursor.getColumnNames();
sb.append("" + cursor.getPosition() + " {\n");
int length = cols.length;
for (int i = 0; i < length; i++) {
String value;
try {
value = cursor.getString(i);
} catch (SQLiteException e) {
// assume that if the getString threw this exception then the column is not
// representable by a string, e.g. it is a BLOB.
value = "<unprintable>";
}
sb.append(" " + cols[i] + '=' + value + "\n");
}
sb.append("}\n");
} | java | public static void dumpCurrentRow(Cursor cursor, StringBuilder sb) {
String[] cols = cursor.getColumnNames();
sb.append("" + cursor.getPosition() + " {\n");
int length = cols.length;
for (int i = 0; i < length; i++) {
String value;
try {
value = cursor.getString(i);
} catch (SQLiteException e) {
// assume that if the getString threw this exception then the column is not
// representable by a string, e.g. it is a BLOB.
value = "<unprintable>";
}
sb.append(" " + cols[i] + '=' + value + "\n");
}
sb.append("}\n");
} | [
"public",
"static",
"void",
"dumpCurrentRow",
"(",
"Cursor",
"cursor",
",",
"StringBuilder",
"sb",
")",
"{",
"String",
"[",
"]",
"cols",
"=",
"cursor",
".",
"getColumnNames",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"\"",
"+",
"cursor",
".",
"getPosition",
"(",
")",
"+",
"\" {\\n\"",
")",
";",
"int",
"length",
"=",
"cols",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"String",
"value",
";",
"try",
"{",
"value",
"=",
"cursor",
".",
"getString",
"(",
"i",
")",
";",
"}",
"catch",
"(",
"SQLiteException",
"e",
")",
"{",
"// assume that if the getString threw this exception then the column is not",
"// representable by a string, e.g. it is a BLOB.",
"value",
"=",
"\"<unprintable>\"",
";",
"}",
"sb",
".",
"append",
"(",
"\" \"",
"+",
"cols",
"[",
"i",
"]",
"+",
"'",
"'",
"+",
"value",
"+",
"\"\\n\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"}\\n\"",
")",
";",
"}"
] | Prints the contents of a Cursor's current row to a StringBuilder.
@param cursor the cursor to print
@param sb the StringBuilder to print to | [
"Prints",
"the",
"contents",
"of",
"a",
"Cursor",
"s",
"current",
"row",
"to",
"a",
"StringBuilder",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L571-L587 |
28,380 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.dumpCurrentRowToString | public static String dumpCurrentRowToString(Cursor cursor) {
StringBuilder sb = new StringBuilder();
dumpCurrentRow(cursor, sb);
return sb.toString();
} | java | public static String dumpCurrentRowToString(Cursor cursor) {
StringBuilder sb = new StringBuilder();
dumpCurrentRow(cursor, sb);
return sb.toString();
} | [
"public",
"static",
"String",
"dumpCurrentRowToString",
"(",
"Cursor",
"cursor",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"dumpCurrentRow",
"(",
"cursor",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Dump the contents of a Cursor's current row to a String.
@param cursor the cursor to print
@return a String that contains the dumped cursor row | [
"Dump",
"the",
"contents",
"of",
"a",
"Cursor",
"s",
"current",
"row",
"to",
"a",
"String",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L595-L599 |
28,381 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorStringToInsertHelper | public static void cursorStringToInsertHelper(Cursor cursor, String field,
InsertHelper inserter, int index) {
inserter.bind(index, cursor.getString(cursor.getColumnIndexOrThrow(field)));
} | java | public static void cursorStringToInsertHelper(Cursor cursor, String field,
InsertHelper inserter, int index) {
inserter.bind(index, cursor.getString(cursor.getColumnIndexOrThrow(field)));
} | [
"public",
"static",
"void",
"cursorStringToInsertHelper",
"(",
"Cursor",
"cursor",
",",
"String",
"field",
",",
"InsertHelper",
"inserter",
",",
"int",
"index",
")",
"{",
"inserter",
".",
"bind",
"(",
"index",
",",
"cursor",
".",
"getString",
"(",
"cursor",
".",
"getColumnIndexOrThrow",
"(",
"field",
")",
")",
")",
";",
"}"
] | Reads a String out of a field in a Cursor and writes it to an InsertHelper.
@param cursor The cursor to read from
@param field The TEXT field to read
@param inserter The InsertHelper to bind into
@param index the index of the bind entry in the InsertHelper | [
"Reads",
"a",
"String",
"out",
"of",
"a",
"field",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"an",
"InsertHelper",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L621-L624 |
28,382 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorIntToContentValues | public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values) {
cursorIntToContentValues(cursor, field, values, field);
} | java | public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values) {
cursorIntToContentValues(cursor, field, values, field);
} | [
"public",
"static",
"void",
"cursorIntToContentValues",
"(",
"Cursor",
"cursor",
",",
"String",
"field",
",",
"ContentValues",
"values",
")",
"{",
"cursorIntToContentValues",
"(",
"cursor",
",",
"field",
",",
"values",
",",
"field",
")",
";",
"}"
] | Reads an Integer out of a field in a Cursor and writes it to a Map.
@param cursor The cursor to read from
@param field The INTEGER field to read
@param values The {@link ContentValues} to put the value into, with the field as the key | [
"Reads",
"an",
"Integer",
"out",
"of",
"a",
"field",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"Map",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L646-L648 |
28,383 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorIntToContentValues | public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values,
String key) {
int colIndex = cursor.getColumnIndex(field);
if (!cursor.isNull(colIndex)) {
values.put(key, cursor.getInt(colIndex));
} else {
values.put(key, (Integer) null);
}
} | java | public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values,
String key) {
int colIndex = cursor.getColumnIndex(field);
if (!cursor.isNull(colIndex)) {
values.put(key, cursor.getInt(colIndex));
} else {
values.put(key, (Integer) null);
}
} | [
"public",
"static",
"void",
"cursorIntToContentValues",
"(",
"Cursor",
"cursor",
",",
"String",
"field",
",",
"ContentValues",
"values",
",",
"String",
"key",
")",
"{",
"int",
"colIndex",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"field",
")",
";",
"if",
"(",
"!",
"cursor",
".",
"isNull",
"(",
"colIndex",
")",
")",
"{",
"values",
".",
"put",
"(",
"key",
",",
"cursor",
".",
"getInt",
"(",
"colIndex",
")",
")",
";",
"}",
"else",
"{",
"values",
".",
"put",
"(",
"key",
",",
"(",
"Integer",
")",
"null",
")",
";",
"}",
"}"
] | Reads a Integer out of a field in a Cursor and writes it to a Map.
@param cursor The cursor to read from
@param field The INTEGER field to read
@param values The {@link ContentValues} to put the value into, with the field as the key
@param key The key to store the value with in the map | [
"Reads",
"a",
"Integer",
"out",
"of",
"a",
"field",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"Map",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L658-L666 |
28,384 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorRowToContentValues | public static void cursorRowToContentValues(Cursor cursor, ContentValues values) {
String[] columns = cursor.getColumnNames();
int length = columns.length;
for (int i = 0; i < length; i++) {
if (cursor.getType(i) == Cursor.FIELD_TYPE_BLOB) {
values.put(columns[i], cursor.getBlob(i));
} else {
values.put(columns[i], cursor.getString(i));
}
}
} | java | public static void cursorRowToContentValues(Cursor cursor, ContentValues values) {
String[] columns = cursor.getColumnNames();
int length = columns.length;
for (int i = 0; i < length; i++) {
if (cursor.getType(i) == Cursor.FIELD_TYPE_BLOB) {
values.put(columns[i], cursor.getBlob(i));
} else {
values.put(columns[i], cursor.getString(i));
}
}
} | [
"public",
"static",
"void",
"cursorRowToContentValues",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
")",
"{",
"String",
"[",
"]",
"columns",
"=",
"cursor",
".",
"getColumnNames",
"(",
")",
";",
"int",
"length",
"=",
"columns",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"cursor",
".",
"getType",
"(",
"i",
")",
"==",
"Cursor",
".",
"FIELD_TYPE_BLOB",
")",
"{",
"values",
".",
"put",
"(",
"columns",
"[",
"i",
"]",
",",
"cursor",
".",
"getBlob",
"(",
"i",
")",
")",
";",
"}",
"else",
"{",
"values",
".",
"put",
"(",
"columns",
"[",
"i",
"]",
",",
"cursor",
".",
"getString",
"(",
"i",
")",
")",
";",
"}",
"}",
"}"
] | Read the entire contents of a cursor row and store them in a ContentValues.
@param cursor the cursor to read from.
@param values the {@link ContentValues} to put the row into. | [
"Read",
"the",
"entire",
"contents",
"of",
"a",
"cursor",
"row",
"and",
"store",
"them",
"in",
"a",
"ContentValues",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L735-L745 |
28,385 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.queryIsEmpty | public static boolean queryIsEmpty(SQLiteDatabase db, String table) {
long isEmpty = longForQuery(db, "select exists(select 1 from " + table + ")", null);
return isEmpty == 0;
} | java | public static boolean queryIsEmpty(SQLiteDatabase db, String table) {
long isEmpty = longForQuery(db, "select exists(select 1 from " + table + ")", null);
return isEmpty == 0;
} | [
"public",
"static",
"boolean",
"queryIsEmpty",
"(",
"SQLiteDatabase",
"db",
",",
"String",
"table",
")",
"{",
"long",
"isEmpty",
"=",
"longForQuery",
"(",
"db",
",",
"\"select exists(select 1 from \"",
"+",
"table",
"+",
"\")\"",
",",
"null",
")",
";",
"return",
"isEmpty",
"==",
"0",
";",
"}"
] | Query the table to check whether a table is empty or not
@param db the database the table is in
@param table the name of the table to query
@return True if the table is empty
@hide | [
"Query",
"the",
"table",
"to",
"check",
"whether",
"a",
"table",
"is",
"empty",
"or",
"not"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L823-L826 |
28,386 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.blobFileDescriptorForQuery | public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteDatabase db,
String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return blobFileDescriptorForQuery(prog, selectionArgs);
} finally {
prog.close();
}
} | java | public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteDatabase db,
String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return blobFileDescriptorForQuery(prog, selectionArgs);
} finally {
prog.close();
}
} | [
"public",
"static",
"ParcelFileDescriptor",
"blobFileDescriptorForQuery",
"(",
"SQLiteDatabase",
"db",
",",
"String",
"query",
",",
"String",
"[",
"]",
"selectionArgs",
")",
"{",
"SQLiteStatement",
"prog",
"=",
"db",
".",
"compileStatement",
"(",
"query",
")",
";",
"try",
"{",
"return",
"blobFileDescriptorForQuery",
"(",
"prog",
",",
"selectionArgs",
")",
";",
"}",
"finally",
"{",
"prog",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Utility method to run the query on the db and return the blob value in the
first column of the first row.
@return A read-only file descriptor for a copy of the blob value. | [
"Utility",
"method",
"to",
"run",
"the",
"query",
"on",
"the",
"db",
"and",
"return",
"the",
"blob",
"value",
"in",
"the",
"first",
"column",
"of",
"the",
"first",
"row",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L878-L886 |
28,387 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.blobFileDescriptorForQuery | public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteStatement prog,
String[] selectionArgs) {
prog.bindAllArgsAsStrings(selectionArgs);
return prog.simpleQueryForBlobFileDescriptor();
} | java | public static ParcelFileDescriptor blobFileDescriptorForQuery(SQLiteStatement prog,
String[] selectionArgs) {
prog.bindAllArgsAsStrings(selectionArgs);
return prog.simpleQueryForBlobFileDescriptor();
} | [
"public",
"static",
"ParcelFileDescriptor",
"blobFileDescriptorForQuery",
"(",
"SQLiteStatement",
"prog",
",",
"String",
"[",
"]",
"selectionArgs",
")",
"{",
"prog",
".",
"bindAllArgsAsStrings",
"(",
"selectionArgs",
")",
";",
"return",
"prog",
".",
"simpleQueryForBlobFileDescriptor",
"(",
")",
";",
"}"
] | Utility method to run the pre-compiled query and return the blob value in the
first column of the first row.
@return A read-only file descriptor for a copy of the blob value. | [
"Utility",
"method",
"to",
"run",
"the",
"pre",
"-",
"compiled",
"query",
"and",
"return",
"the",
"blob",
"value",
"in",
"the",
"first",
"column",
"of",
"the",
"first",
"row",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L894-L898 |
28,388 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorStringToContentValuesIfPresent | public static void cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getString(index));
}
} | java | public static void cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getString(index));
}
} | [
"public",
"static",
"void",
"cursorStringToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getString",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a String out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"String",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L908-L914 |
28,389 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorLongToContentValuesIfPresent | public static void cursorLongToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getLong(index));
}
} | java | public static void cursorLongToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getLong(index));
}
} | [
"public",
"static",
"void",
"cursorLongToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getLong",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a Long out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"Long",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L924-L930 |
28,390 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorShortToContentValuesIfPresent | public static void cursorShortToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getShort(index));
}
} | java | public static void cursorShortToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getShort(index));
}
} | [
"public",
"static",
"void",
"cursorShortToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getShort",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a Short out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"Short",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L940-L946 |
28,391 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorIntToContentValuesIfPresent | public static void cursorIntToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getInt(index));
}
} | java | public static void cursorIntToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getInt(index));
}
} | [
"public",
"static",
"void",
"cursorIntToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getInt",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a Integer out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"Integer",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L956-L962 |
28,392 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorFloatToContentValuesIfPresent | public static void cursorFloatToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getFloat(index));
}
} | java | public static void cursorFloatToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getFloat(index));
}
} | [
"public",
"static",
"void",
"cursorFloatToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getFloat",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a Float out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"Float",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L972-L978 |
28,393 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.cursorDoubleToContentValuesIfPresent | public static void cursorDoubleToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getDouble(index));
}
} | java | public static void cursorDoubleToContentValuesIfPresent(Cursor cursor, ContentValues values,
String column) {
final int index = cursor.getColumnIndex(column);
if (index != -1 && !cursor.isNull(index)) {
values.put(column, cursor.getDouble(index));
}
} | [
"public",
"static",
"void",
"cursorDoubleToContentValuesIfPresent",
"(",
"Cursor",
"cursor",
",",
"ContentValues",
"values",
",",
"String",
"column",
")",
"{",
"final",
"int",
"index",
"=",
"cursor",
".",
"getColumnIndex",
"(",
"column",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
"&&",
"!",
"cursor",
".",
"isNull",
"(",
"index",
")",
")",
"{",
"values",
".",
"put",
"(",
"column",
",",
"cursor",
".",
"getDouble",
"(",
"index",
")",
")",
";",
"}",
"}"
] | Reads a Double out of a column in a Cursor and writes it to a ContentValues.
Adds nothing to the ContentValues if the column isn't present or if its value is null.
@param cursor The cursor to read from
@param column The column to read
@param values The {@link ContentValues} to put the value into | [
"Reads",
"a",
"Double",
"out",
"of",
"a",
"column",
"in",
"a",
"Cursor",
"and",
"writes",
"it",
"to",
"a",
"ContentValues",
".",
"Adds",
"nothing",
"to",
"the",
"ContentValues",
"if",
"the",
"column",
"isn",
"t",
"present",
"or",
"if",
"its",
"value",
"is",
"null",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L988-L994 |
28,394 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.createDbFromSqlStatements | static public void createDbFromSqlStatements(
Context context, String dbName, int dbVersion, String sqlStatements) {
File f = context.getDatabasePath(dbName);
f.getParentFile().mkdirs();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(f, null);
// TODO: this is not quite safe since it assumes that all semicolons at the end of a line
// terminate statements. It is possible that a text field contains ;\n. We will have to fix
// this if that turns out to be a problem.
String[] statements = TextUtils.split(sqlStatements, ";\n");
for (String statement : statements) {
if (TextUtils.isEmpty(statement)) continue;
db.execSQL(statement);
}
db.setVersion(dbVersion);
db.close();
} | java | static public void createDbFromSqlStatements(
Context context, String dbName, int dbVersion, String sqlStatements) {
File f = context.getDatabasePath(dbName);
f.getParentFile().mkdirs();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(f, null);
// TODO: this is not quite safe since it assumes that all semicolons at the end of a line
// terminate statements. It is possible that a text field contains ;\n. We will have to fix
// this if that turns out to be a problem.
String[] statements = TextUtils.split(sqlStatements, ";\n");
for (String statement : statements) {
if (TextUtils.isEmpty(statement)) continue;
db.execSQL(statement);
}
db.setVersion(dbVersion);
db.close();
} | [
"static",
"public",
"void",
"createDbFromSqlStatements",
"(",
"Context",
"context",
",",
"String",
"dbName",
",",
"int",
"dbVersion",
",",
"String",
"sqlStatements",
")",
"{",
"File",
"f",
"=",
"context",
".",
"getDatabasePath",
"(",
"dbName",
")",
";",
"f",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"SQLiteDatabase",
"db",
"=",
"SQLiteDatabase",
".",
"openOrCreateDatabase",
"(",
"f",
",",
"null",
")",
";",
"// TODO: this is not quite safe since it assumes that all semicolons at the end of a line",
"// terminate statements. It is possible that a text field contains ;\\n. We will have to fix",
"// this if that turns out to be a problem.",
"String",
"[",
"]",
"statements",
"=",
"TextUtils",
".",
"split",
"(",
"sqlStatements",
",",
"\";\\n\"",
")",
";",
"for",
"(",
"String",
"statement",
":",
"statements",
")",
"{",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"statement",
")",
")",
"continue",
";",
"db",
".",
"execSQL",
"(",
"statement",
")",
";",
"}",
"db",
".",
"setVersion",
"(",
"dbVersion",
")",
";",
"db",
".",
"close",
"(",
")",
";",
"}"
] | Creates a db and populates it with the sql statements in sqlStatements.
@param context the context to use to create the db
@param dbName the name of the db to create
@param dbVersion the version to set on the db
@param sqlStatements the statements to use to populate the db. This should be a single string
of the form returned by sqlite3's <tt>.dump</tt> command (statements separated by
semicolons) | [
"Creates",
"a",
"db",
"and",
"populates",
"it",
"with",
"the",
"sql",
"statements",
"in",
"sqlStatements",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L1367-L1384 |
28,395 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.appendSelectionArgs | public static String[] appendSelectionArgs(String[] originalValues, String[] newValues) {
if (originalValues == null || originalValues.length == 0) {
return newValues;
}
String[] result = new String[originalValues.length + newValues.length ];
System.arraycopy(originalValues, 0, result, 0, originalValues.length);
System.arraycopy(newValues, 0, result, originalValues.length, newValues.length);
return result;
} | java | public static String[] appendSelectionArgs(String[] originalValues, String[] newValues) {
if (originalValues == null || originalValues.length == 0) {
return newValues;
}
String[] result = new String[originalValues.length + newValues.length ];
System.arraycopy(originalValues, 0, result, 0, originalValues.length);
System.arraycopy(newValues, 0, result, originalValues.length, newValues.length);
return result;
} | [
"public",
"static",
"String",
"[",
"]",
"appendSelectionArgs",
"(",
"String",
"[",
"]",
"originalValues",
",",
"String",
"[",
"]",
"newValues",
")",
"{",
"if",
"(",
"originalValues",
"==",
"null",
"||",
"originalValues",
".",
"length",
"==",
"0",
")",
"{",
"return",
"newValues",
";",
"}",
"String",
"[",
"]",
"result",
"=",
"new",
"String",
"[",
"originalValues",
".",
"length",
"+",
"newValues",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"originalValues",
",",
"0",
",",
"result",
",",
"0",
",",
"originalValues",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"newValues",
",",
"0",
",",
"result",
",",
"originalValues",
".",
"length",
",",
"newValues",
".",
"length",
")",
";",
"return",
"result",
";",
"}"
] | Appends one set of selection args to another. This is useful when adding a selection
argument to a user provided set. | [
"Appends",
"one",
"set",
"of",
"selection",
"args",
"to",
"another",
".",
"This",
"is",
"useful",
"when",
"adding",
"a",
"selection",
"argument",
"to",
"a",
"user",
"provided",
"set",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L1438-L1446 |
28,396 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java | DatabaseUtils.findRowIdColumnIndex | public static int findRowIdColumnIndex(String[] columnNames) {
int length = columnNames.length;
for (int i = 0; i < length; i++) {
if (columnNames[i].equals("_id")) {
return i;
}
}
return -1;
} | java | public static int findRowIdColumnIndex(String[] columnNames) {
int length = columnNames.length;
for (int i = 0; i < length; i++) {
if (columnNames[i].equals("_id")) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"findRowIdColumnIndex",
"(",
"String",
"[",
"]",
"columnNames",
")",
"{",
"int",
"length",
"=",
"columnNames",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"columnNames",
"[",
"i",
"]",
".",
"equals",
"(",
"\"_id\"",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns column index of "_id" column, or -1 if not found.
@hide | [
"Returns",
"column",
"index",
"of",
"_id",
"column",
"or",
"-",
"1",
"if",
"not",
"found",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/DatabaseUtils.java#L1452-L1460 |
28,397 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.getPixelRelativeToTile | public static Point getPixelRelativeToTile(LatLong latLong, Tile tile) {
return getPixelRelative(latLong, tile.mapSize, tile.getOrigin());
} | java | public static Point getPixelRelativeToTile(LatLong latLong, Tile tile) {
return getPixelRelative(latLong, tile.mapSize, tile.getOrigin());
} | [
"public",
"static",
"Point",
"getPixelRelativeToTile",
"(",
"LatLong",
"latLong",
",",
"Tile",
"tile",
")",
"{",
"return",
"getPixelRelative",
"(",
"latLong",
",",
"tile",
".",
"mapSize",
",",
"tile",
".",
"getOrigin",
"(",
")",
")",
";",
"}"
] | Calculates the absolute pixel position for a tile and tile size relative to origin
@param latLong the geographic position.
@param tile tile
@return the relative pixel position to the origin values (e.g. for a tile) | [
"Calculates",
"the",
"absolute",
"pixel",
"position",
"for",
"a",
"tile",
"and",
"tile",
"size",
"relative",
"to",
"origin"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L175-L177 |
28,398 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.metersToPixelsWithScaleFactor | public static double metersToPixelsWithScaleFactor(float meters, double latitude, double scaleFactor, int tileSize) {
return meters / MercatorProjection.calculateGroundResolutionWithScaleFactor(latitude, scaleFactor, tileSize);
} | java | public static double metersToPixelsWithScaleFactor(float meters, double latitude, double scaleFactor, int tileSize) {
return meters / MercatorProjection.calculateGroundResolutionWithScaleFactor(latitude, scaleFactor, tileSize);
} | [
"public",
"static",
"double",
"metersToPixelsWithScaleFactor",
"(",
"float",
"meters",
",",
"double",
"latitude",
",",
"double",
"scaleFactor",
",",
"int",
"tileSize",
")",
"{",
"return",
"meters",
"/",
"MercatorProjection",
".",
"calculateGroundResolutionWithScaleFactor",
"(",
"latitude",
",",
"scaleFactor",
",",
"tileSize",
")",
";",
"}"
] | Converts meters to pixels at latitude for zoom-level.
@param meters the meters to convert
@param latitude the latitude for the conversion.
@param scaleFactor the scale factor for the conversion.
@return pixels that represent the meters at the given zoom-level and latitude. | [
"Converts",
"meters",
"to",
"pixels",
"at",
"latitude",
"for",
"zoom",
"-",
"level",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L312-L314 |
28,399 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.pixelXToLongitudeWithScaleFactor | public static double pixelXToLongitudeWithScaleFactor(double pixelX, double scaleFactor, int tileSize) {
long mapSize = getMapSizeWithScaleFactor(scaleFactor, tileSize);
if (pixelX < 0 || pixelX > mapSize) {
throw new IllegalArgumentException("invalid pixelX coordinate at scale " + scaleFactor + ": " + pixelX);
}
return 360 * ((pixelX / mapSize) - 0.5);
} | java | public static double pixelXToLongitudeWithScaleFactor(double pixelX, double scaleFactor, int tileSize) {
long mapSize = getMapSizeWithScaleFactor(scaleFactor, tileSize);
if (pixelX < 0 || pixelX > mapSize) {
throw new IllegalArgumentException("invalid pixelX coordinate at scale " + scaleFactor + ": " + pixelX);
}
return 360 * ((pixelX / mapSize) - 0.5);
} | [
"public",
"static",
"double",
"pixelXToLongitudeWithScaleFactor",
"(",
"double",
"pixelX",
",",
"double",
"scaleFactor",
",",
"int",
"tileSize",
")",
"{",
"long",
"mapSize",
"=",
"getMapSizeWithScaleFactor",
"(",
"scaleFactor",
",",
"tileSize",
")",
";",
"if",
"(",
"pixelX",
"<",
"0",
"||",
"pixelX",
">",
"mapSize",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid pixelX coordinate at scale \"",
"+",
"scaleFactor",
"+",
"\": \"",
"+",
"pixelX",
")",
";",
"}",
"return",
"360",
"*",
"(",
"(",
"pixelX",
"/",
"mapSize",
")",
"-",
"0.5",
")",
";",
"}"
] | Converts a pixel X coordinate at a certain scale to a longitude coordinate.
@param pixelX the pixel X coordinate that should be converted.
@param scaleFactor the scale factor at which the coordinate should be converted.
@return the longitude value of the pixel X coordinate.
@throws IllegalArgumentException if the given pixelX coordinate is invalid. | [
"Converts",
"a",
"pixel",
"X",
"coordinate",
"at",
"a",
"certain",
"scale",
"to",
"a",
"longitude",
"coordinate",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L336-L342 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.