remove unnecessary changes
This commit is contained in:
parent
b0ed02c597
commit
b2e637ae44
3 changed files with 4 additions and 102 deletions
|
@ -298,7 +298,6 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
ser.attribute(null, "generator", Version.getAppName(ctx)); //$NON-NLS-1$
|
||||
if (n instanceof Node) {
|
||||
writeNode((Node) n, info, ser, changeSetId, settings.USER_NAME.get());
|
||||
|
||||
} else if (n instanceof Way) {
|
||||
writeWay((Way) n, info, ser, changeSetId, settings.USER_NAME.get());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
@ -19,7 +18,6 @@ import java.util.List;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import gnu.trove.list.array.TLongArrayList;
|
||||
|
||||
public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
||||
|
||||
|
@ -35,15 +33,6 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
private static final String OPENSTREETMAP_COL_CHANGED_TAGS = "changed_tags";
|
||||
private static final String OPENSTREETMAP_COL_ENTITY_TYPE = "entity_type";
|
||||
|
||||
private static final String WAY_NODES_IDS_TABLE_NAME = "way_nodes_ids_table";
|
||||
private static final String WAY_COL_ID = "id";
|
||||
private static final String NODES_COL_IDS = "node_id";
|
||||
|
||||
private static final String WAY_NODES_IDS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
|
||||
WAY_NODES_IDS_TABLE_NAME + " (" +
|
||||
WAY_COL_ID + " int , " +
|
||||
NODES_COL_IDS + " int);";
|
||||
|
||||
private static final String OPENSTREETMAP_TABLE_CREATE = "CREATE TABLE " + OPENSTREETMAP_TABLE_NAME + " (" + //$NON-NLS-1$ //$NON-NLS-2$
|
||||
OPENSTREETMAP_COL_ID + " bigint,"+
|
||||
OPENSTREETMAP_COL_LAT + " double," + OPENSTREETMAP_COL_LON + " double," +
|
||||
|
@ -59,7 +48,6 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(OPENSTREETMAP_TABLE_CREATE);
|
||||
db.execSQL(WAY_NODES_IDS_TABLE_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,10 +61,8 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
if (oldVersion < 6) {
|
||||
db.execSQL("ALTER TABLE " + OPENSTREETMAP_TABLE_NAME + " ADD " + OPENSTREETMAP_COL_ENTITY_TYPE + " TEXT");
|
||||
db.execSQL("UPDATE " + OPENSTREETMAP_TABLE_NAME +
|
||||
" SET " + OPENSTREETMAP_COL_ENTITY_TYPE + " = ? " +
|
||||
db.execSQL("UPDATE " + OPENSTREETMAP_TABLE_NAME + " SET " + OPENSTREETMAP_COL_ENTITY_TYPE + " = ? " +
|
||||
"WHERE " + OPENSTREETMAP_COL_ENTITY_TYPE + " IS NULL", new String[]{Entity.EntityType.NODE.toString()});
|
||||
db.execSQL(WAY_NODES_IDS_TABLE_CREATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,9 +116,6 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
OsmPoint.stringAction.get(p.getAction()), p.getComment(),
|
||||
chTags == null ? null : changedTags.toString(), Entity.EntityType.valueOf(entity)});
|
||||
|
||||
if (Entity.EntityType.valueOf(entity) == Entity.EntityType.WAY) {
|
||||
addNodeIdsForWay((Way) entity);
|
||||
}
|
||||
db.close();
|
||||
checkOpenstreetmapPoints();
|
||||
return true;
|
||||
|
@ -140,18 +123,11 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean deletePOI(OpenstreetmapPoint p) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
db.execSQL("DELETE FROM " + OPENSTREETMAP_TABLE_NAME +
|
||||
" WHERE " + OPENSTREETMAP_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
Entity entity = p.getEntity();
|
||||
if (Entity.EntityType.valueOf(entity) == Entity.EntityType.WAY) {
|
||||
db.execSQL("DELETE FROM " + WAY_NODES_IDS_TABLE_NAME +
|
||||
" WHERE " + WAY_COL_ID + " = ?", new Object[]{entity.getId()});
|
||||
}
|
||||
db.close();
|
||||
checkOpenstreetmapPoints();
|
||||
return true;
|
||||
|
@ -159,7 +135,6 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
private List<OpenstreetmapPoint> checkOpenstreetmapPoints(){
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
List<OpenstreetmapPoint> points = new ArrayList<OpenstreetmapPoint>();
|
||||
|
@ -184,7 +159,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
query.getDouble(2),
|
||||
query.getLong(0));
|
||||
} else if (entityType != null && Entity.EntityType.valueOf(entityType) == Entity.EntityType.WAY) {
|
||||
entity = new Way(query.getLong(0), getNodeIdsForWayId(query.getLong(0)),
|
||||
entity = new Way(query.getLong(0), null,
|
||||
query.getDouble(1),
|
||||
query.getDouble(2));
|
||||
}
|
||||
|
@ -212,49 +187,6 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
return points;
|
||||
}
|
||||
|
||||
|
||||
private void addNodeIdsForWay(Way way) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
try {
|
||||
ContentValues values = new ContentValues();
|
||||
db.execSQL("DELETE FROM " + WAY_NODES_IDS_TABLE_NAME +
|
||||
" WHERE " + WAY_COL_ID + " = ?", new Object[]{way.getId()});
|
||||
|
||||
db.beginTransaction();
|
||||
for (Long nodeId : way.getNodeIds().toArray()) {
|
||||
if (nodeId != 0) {
|
||||
values.put(WAY_COL_ID, way.getId());
|
||||
values.put(NODES_COL_IDS, nodeId);
|
||||
db.insert(WAY_NODES_IDS_TABLE_NAME, null, values);
|
||||
}
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TLongArrayList getNodeIdsForWayId(long id) {
|
||||
TLongArrayList nodeIds = new TLongArrayList();
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
if (db != null) {
|
||||
Cursor query = db.rawQuery("SELECT " + NODES_COL_IDS + " FROM " +
|
||||
WAY_NODES_IDS_TABLE_NAME + " WHERE " + OPENSTREETMAP_COL_ID + " = ?",
|
||||
new String[]{String.valueOf(id)});
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
nodeIds.add(query.getLong(0));
|
||||
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
}
|
||||
return nodeIds;
|
||||
}
|
||||
|
||||
public long getMinID() {
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
long minID = 0;
|
||||
|
|
|
@ -820,12 +820,8 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
|
||||
if (p.getAction() == a) {
|
||||
Entity entity = p.getEntity();
|
||||
if (entity != null) {
|
||||
if (Entity.EntityType.valueOf(entity) == Entity.EntityType.NODE) {
|
||||
writeNode(sz, (Node) p.getEntity());
|
||||
} else if (Entity.EntityType.valueOf(entity) == Entity.EntityType.WAY) {
|
||||
writeWay(sz, (Way) p.getEntity());
|
||||
}
|
||||
if (entity != null && entity instanceof Node) {
|
||||
writeNode(sz, (Node) entity);
|
||||
}
|
||||
}
|
||||
} else if (point.getGroup() == Group.BUG) {
|
||||
|
@ -858,31 +854,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
}
|
||||
}
|
||||
|
||||
private void writeWay(XmlSerializer sz, Way p) {
|
||||
try {
|
||||
sz.startTag("", "way");
|
||||
sz.attribute("", "id", p.getId() + "");
|
||||
sz.attribute("", "version", "1");
|
||||
for (Long nodeRefId : p.getNodeIds().toArray()) {
|
||||
String val = String.valueOf(nodeRefId);
|
||||
if (val.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
sz.startTag("", "nd");
|
||||
sz.attribute("", "ref", val);
|
||||
sz.endTag("", "nd");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
writeTags(sz, p);
|
||||
sz.endTag("", "way");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeTags(XmlSerializer sz, Entity p) {
|
||||
for (String tag : p.getTagKeySet()) {
|
||||
String val = p.getTag(tag);
|
||||
|
|
Loading…
Reference in a new issue