public class VectorLayer extends Layer

The vector layer class. It stores geometry and attributes.

Here some examples of code to work with this layer.

To put image to the feature Uri newUri = … content://com.nextgis.mobile.provider/layer_xxxxxxxxx/1/attach Uri uri = getContentResolver().insert(newUri, null); try { OutputStream outStream = getContentResolver().openOutputStream(uri); sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream); outStream.close(); } catch (Exception e) { Log.e(TAG, “exception while writing image”, e); }

To get bitmap from uri private Bitmap getBitmapFromUri(Uri uri) throws IOException { ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri, “r”); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor); parcelFileDescriptor.close(); return image; } To get image using uri Uri featureUri = content://com.nextgis.mobile.provider/layer_xxxxxxxxx/1 Uri thisAttachUri = ContentUris.withAppendedId(featureUri, attachId); InputStream inStream = null; try { inStream = resolver.openInputStream(thisAttachUri); // what to do with the stream is up to you // I simply create a bitmap to display it Bitmap bm = BitmapFactory.decodeStream(inStream); FrameLayout frame = (FrameLayout)findViewById(R.id.picture_frame); ImageView view = new ImageView(getApplicationContext()); view.setImageBitmap(bm); frame.addView(view); } catch (FileNotFoundException e) { Log.e(TAG, “file not found ” + thisAttachUri, e); } finally { if (inStream != null) { try { inStream.close(); } catch (IOException e) { Log.e(TAG, “could not close stream”, e); } }

Also it can be used Uri newUri = … content://com.nextgis.mobile.provider/layer_xxxxxxxxx/1/attach Cursor cursor = resolver.query(newUri, {MediaStore.MediaColumns.DATA}, null….) File bitmapFile = new File(cursor.getString(ATTACH_DATA)) and open using real path

Author:Dmitry Baryshnikov Fields ATTACH_DATA

public static final String ATTACH_DATA ATTACH_DATE_ADDED



public static final String ATTACH_DISPLAY_NAME ATTACH_ID

public static final String ATTACH_ID ATTACH_MIME_TYPE

public static final String ATTACH_MIME_TYPE ATTACH_SIZE

public static final String ATTACH_SIZE COLUMN_TYPE_LONG




protected static final String CONTENT_ATTACH_TYPE CONTENT_ITEM_TYPE

protected static String CONTENT_ITEM_TYPE CONTENT_TYPE

protected static String CONTENT_TYPE JSON_FIELDS_KEY

protected static final String JSON_FIELDS_KEY JSON_GEOMETRY_TYPE_KEY

protected static final String JSON_GEOMETRY_TYPE_KEY META

protected static final String META NO_SYNC

protected static final String NO_SYNC RTREE

protected static final String RTREE TYPE_ATTACH

protected static final int TYPE_ATTACH TYPE_ATTACH_ID

protected static final int TYPE_ATTACH_ID TYPE_FEATURE

protected static final int TYPE_FEATURE TYPE_TABLE

protected static final int TYPE_TABLE mAuthority

protected static String mAuthority mCache

protected IGeometryCache mCache

The geometry cache for fast querying and drawing mCacheLoaded

protected boolean mCacheLoaded mFields

protected Map<String, Field> mFields mGeometryType

protected int mGeometryType mIgnoreFeatures

protected List<Long> mIgnoreFeatures mIsLocked

protected boolean mIsLocked mUniqId

protected long mUniqId mUriMatcher

protected static UriMatcher mUriMatcher Constructors VectorLayer

public VectorLayer(Context context, File path) Methods addAttach

protected void addAttach(String featureId, AttachItem item) addChange

public void addChange(long featureId, int operation) addChange

public void addChange(long featureId, long attachId, int attachOperation) cacheGeometryEnvelope

protected void cacheGeometryEnvelope(long rowId, GeoGeometry geoGeometry) checkGeometryType

protected boolean checkGeometryType(Feature feature) checkPointOverlaps

protected boolean checkPointOverlaps(GeoPoint pt, double tolerance) create

public void create(int geometryType, List<Field> fields) createFeature

public long createFeature(Feature feature) createFeatureBatch

public void createFeatureBatch(Feature feature, SQLiteDatabase db) createField

public void createField(Field field) createFromGeoJson

public void createFromGeoJson(Uri uri, IProgressor progressor) createFromGeoJson

public void createFromGeoJson(File path, IProgressor progressor) createNewCache

protected IGeometryCache createNewCache() cursorToFeature

public Feature cursorToFeature(Cursor cursor) delete

public boolean delete() delete

protected int delete(long rowId, String selection, String[] selectionArgs) delete

public final int delete(Uri uri, String selection, String[] selectionArgs) deleteAddChanges

public int deleteAddChanges(long id)

Delete feature and add information to changes table for sync purposes

  • id – Feature identificator to delete

Count of deleted features deleteAllFeatures

public void deleteAllFeatures(IProgressor progressor) deleteAllTempAttaches

public void deleteAllTempAttaches() deleteAllTempAttachesFlags

public int deleteAllTempAttachesFlags() deleteAllTempFeatures

public void deleteAllTempFeatures() deleteAllTempFeaturesFlags

public int deleteAllTempFeaturesFlags() deleteAllTemps

public void deleteAllTemps() deleteAttach

protected void deleteAttach(String featureId, String attachId) deleteAttachWithFlags

public int deleteAttachWithFlags(long featureId, long attachId) deleteAttaches

protected void deleteAttaches(String featureId) deleteInternal

protected int deleteInternal(Uri uri, int uriType, String selection, String[] selectionArgs) fillFromGeoJson

public void fillFromGeoJson(Uri uri, int srs, IProgressor progressor) fillFromGeoJson

public void fillFromGeoJson(File path, int srs, IProgressor progressor) fromJSON

public void fromJSON(JSONObject jsonObject) getAttach

protected AttachItem getAttach(String featureId, String attachId) getAttachMap

public Map<String, AttachItem> getAttachMap(String featureId) getContentUri

protected Uri getContentUri() getCount

public int getCount() getDefaultStyle

public Style getDefaultStyle() getFeature

public Feature getFeature(long featureId) getFeatureContentValues

protected ContentValues getFeatureContentValues(Feature feature) getFeatureWithAttaches

public Feature getFeatureWithAttaches(long featureId) getFieldByName

public Field getFieldByName(String name) getFields

public List<Field> getFields() getGeometryForId

public GeoGeometry getGeometryForId(long rowId) getGeometryForId

public GeoGeometry getGeometryForId(long rowId, SQLiteDatabase db) getGeometryForId

public GeoGeometry getGeometryForId(long rowId, int zoom) getGeometryForId

public GeoGeometry getGeometryForId(long rowId, int zoom, SQLiteDatabase db) getGeometryFromQuery

protected GeoGeometry getGeometryFromQuery(String[] columns, String selection, SQLiteDatabase db) getGeometryType

public int getGeometryType() getNewTempAttach

public AttachItem getNewTempAttach(Feature feature) getNewTempFeature

public Feature getNewTempFeature() getPreferences

public SharedPreferences getPreferences() getStreamTypes

public String[] getStreamTypes(Uri uri, String mimeTypeFilter) getStyleRule

protected IStyleRule getStyleRule() getType

public String getType(Uri uri) getUniqId

public long getUniqId() hasAttachChanges

protected boolean hasAttachChanges(long featureId, long attachId) hasAttachNotSyncFlag

public boolean hasAttachNotSyncFlag(long featureId, long attachId) hasAttachTempFlag

public boolean hasAttachTempFlag(long featureId, long attachId) hasFeatureAttaches

public boolean hasFeatureAttaches(long featureId) hasFeatureChanges

protected boolean hasFeatureChanges(long featureId) hasFeatureNotSyncFlag

public boolean hasFeatureNotSyncFlag(long featureId) hasFeatureTempFlag

public boolean hasFeatureTempFlag(long featureId) haveFeaturesNotSyncFlag

protected boolean haveFeaturesNotSyncFlag() hideFeature

public void hideFeature(long featureId) insert

protected long insert(ContentValues contentValues) insert

public Uri insert(Uri uri, ContentValues contentValues) insertAddChanges

public long insertAddChanges(ContentValues contentValues)

Insert new values and add information to changes table for sync purposes

  • contentValues – Values to add

New row identifiactor or -1 insertAttach

protected long insertAttach(String featureId, ContentValues contentValues) insertAttachFile

public boolean insertAttachFile(long featureId, long attachId, InputStream inputStream) insertInternal

protected long insertInternal(ContentValues contentValues) insertTempAttach

protected Uri insertTempAttach(long featureId, AttachItem attachItem) insertTempFeature

protected Uri insertTempFeature(Feature feature) isChanges

public boolean isChanges() isFeatureHidden

public boolean isFeatureHidden(long featureId) isFieldsInitialized

public boolean isFieldsInitialized() isLocked

public boolean isLocked() isValid

public boolean isValid() loadAttach

protected Map<String, AttachItem> loadAttach(String featureId) notifyDelete

public void notifyDelete(long rowId) notifyDeleteAll

public void notifyDeleteAll() notifyInsert

public void notifyInsert(long rowId) notifyUpdate

public void notifyUpdate(long rowId, long oldRowId, boolean attributesOnly) notifyUpdateAll

public void notifyUpdateAll() onUpgrade

public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) openFile

public ParcelFileDescriptor openFile(Uri uri, String mode) prepareGeometry

protected void prepareGeometry(ContentValues values) query

public Cursor query(String[] projection, String selection, String[] selectionArgs, String sortOrder, String limit)

In a selection are allowed bbox question:

selection = "_id = 3 AND bbox=[123, 233, 3432, 23444] OR _id = 5";

Are allowed:

"bbox=[-1,-2.3,34.2,56]" or "bbox =  [  -1 , -2.3, 34.2 ,56 ]"
in bbox --  "bbox=[..]", "bbox==[..]"
out bbox -- "bbox!=[..]", "bbox<>[..]" query

public final Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, String limit) query

public List<Long> query(GeoEnvelope env) queryFirstTempAttachFlags

public Cursor queryFirstTempAttachFlags() queryFirstTempFeatureFlags

public Cursor queryFirstTempFeatureFlags() queryInternal

protected Cursor queryInternal(Uri uri, int uriType, String[] projection, String selection, String[] selectionArgs, String sortOrder, String limit) rebuildCache

public void rebuildCache(IProgressor progressor) reloadCache

protected synchronized void reloadCache() reportError

protected void reportError(String error) saveAttach

protected void saveAttach(String featureId, Map<String, AttachItem> attachMap) setAttachNotSyncFlag

public long setAttachNotSyncFlag(long featureId, long attachId, boolean flag) setAttachTempFlag

public long setAttachTempFlag(long featureId, long attachId, boolean flag) setAttachesNotSyncFlag

public long setAttachesNotSyncFlag(long featureId, boolean flag) setAttachesTempFlag

public long setAttachesTempFlag(long featureId, boolean flag) setDefaultRenderer

protected void setDefaultRenderer() setFeatureNotSyncFlag

public long setFeatureNotSyncFlag(long featureId, boolean flag) setFeatureTempFlag

public long setFeatureTempFlag(long featureId, boolean flag) setFeatureWithAttachesNotSyncFlag

public long setFeatureWithAttachesNotSyncFlag(Feature feature, boolean flag) setFeatureWithAttachesNotSyncFlag

public long setFeatureWithAttachesNotSyncFlag(long featureId, boolean flag) setFeatureWithAttachesTempFlag

public long setFeatureWithAttachesTempFlag(Feature feature, boolean flag) setFeatureWithAttachesTempFlag

public long setFeatureWithAttachesTempFlag(long featureId, boolean flag) setLocked

public void setLocked(boolean state) setNewAttachId

protected void setNewAttachId(String featureId, AttachItem item, String newAttachId) setRenderer

protected void setRenderer(JSONObject jsonObject) showAllFeatures

public void showAllFeatures() showFeature

public void showFeature(long featureId) swapFeaturesVisibility

public void swapFeaturesVisibility(long previousFeatureId, long featureId) toJSON

public JSONObject toJSON() toNGW

public void toNGW(Long id, String account, int syncType, Pair<Integer, Integer> ver) update

protected int update(long rowId, ContentValues values, String selection, String[] selectionArgs) update

public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) updateAddChanges

public int updateAddChanges(ContentValues values, long id)

Change feature and add information to changes table for sync purposes

  • values – New values to set
  • id – Feature identificator

Count of changed features updateAttach

public int updateAttach(Feature feature, AttachItem attachItem) updateAttachWithFlags

public int updateAttachWithFlags(Feature feature, AttachItem attachItem) updateFeature

public int updateFeature(Feature feature) updateFeatureWithAttaches

public int updateFeatureWithAttaches(Feature feature) updateFeatureWithAttachesWithFlags

public int updateFeatureWithAttachesWithFlags(Feature feature) updateFeatureWithFlags

public int updateFeatureWithFlags(Feature feature) updateUniqId

protected void updateUniqId(long id)