6.3.1.7.21. VectorLayer

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

6.3.1.7.21.1. Fields

6.3.1.7.21.1.1. ATTACH_DATA

public static final String ATTACH_DATA

6.3.1.7.21.1.2. ATTACH_DATE_ADDED

public static final String ATTACH_DATE_ADDED

6.3.1.7.21.1.3. ATTACH_DESCRIPTION

public static final String ATTACH_DESCRIPTION

6.3.1.7.21.1.4. ATTACH_DISPLAY_NAME

public static final String ATTACH_DISPLAY_NAME

6.3.1.7.21.1.5. ATTACH_ID

public static final String ATTACH_ID

6.3.1.7.21.1.6. ATTACH_MIME_TYPE

public static final String ATTACH_MIME_TYPE

6.3.1.7.21.1.7. ATTACH_SIZE

public static final String ATTACH_SIZE

6.3.1.7.21.1.8. COLUMN_TYPE_LONG

public static final int COLUMN_TYPE_LONG

6.3.1.7.21.1.9. COLUMN_TYPE_STRING

public static final int COLUMN_TYPE_STRING

6.3.1.7.21.1.10. COLUMN_TYPE_UNKNOWN

public static final int COLUMN_TYPE_UNKNOWN

6.3.1.7.21.1.11. CONTENT_ATTACH_TYPE

protected static final String CONTENT_ATTACH_TYPE

6.3.1.7.21.1.12. CONTENT_ITEM_TYPE

protected static String CONTENT_ITEM_TYPE

6.3.1.7.21.1.13. CONTENT_TYPE

protected static String CONTENT_TYPE

6.3.1.7.21.1.14. JSON_FIELDS_KEY

protected static final String JSON_FIELDS_KEY

6.3.1.7.21.1.15. JSON_GEOMETRY_TYPE_KEY

protected static final String JSON_GEOMETRY_TYPE_KEY

6.3.1.7.21.1.16. META

protected static final String META

6.3.1.7.21.1.17. NO_SYNC

protected static final String NO_SYNC

6.3.1.7.21.1.18. RTREE

protected static final String RTREE

6.3.1.7.21.1.19. TYPE_ATTACH

protected static final int TYPE_ATTACH

6.3.1.7.21.1.20. TYPE_ATTACH_ID

protected static final int TYPE_ATTACH_ID

6.3.1.7.21.1.21. TYPE_FEATURE

protected static final int TYPE_FEATURE

6.3.1.7.21.1.22. TYPE_TABLE

protected static final int TYPE_TABLE

6.3.1.7.21.1.23. mAuthority

protected static String mAuthority

6.3.1.7.21.1.24. mCache

protected IGeometryCache mCache

The geometry cache for fast querying and drawing

6.3.1.7.21.1.25. mCacheLoaded

protected boolean mCacheLoaded

6.3.1.7.21.1.26. mFields

protected Map<String, Field> mFields

6.3.1.7.21.1.27. mGeometryType

protected int mGeometryType

6.3.1.7.21.1.28. mIgnoreFeatures

protected List<Long> mIgnoreFeatures

6.3.1.7.21.1.29. mIsLocked

protected boolean mIsLocked

6.3.1.7.21.1.30. mUniqId

protected long mUniqId

6.3.1.7.21.1.31. mUriMatcher

protected static UriMatcher mUriMatcher

6.3.1.7.21.2. Constructors

6.3.1.7.21.2.1. VectorLayer

public VectorLayer(Context context, File path)

6.3.1.7.21.3. Methods

6.3.1.7.21.3.1. addAttach

protected void addAttach(String featureId, AttachItem item)

6.3.1.7.21.3.2. addChange

public void addChange(long featureId, int operation)

6.3.1.7.21.3.3. addChange

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

6.3.1.7.21.3.4. cacheGeometryEnvelope

protected void cacheGeometryEnvelope(long rowId, GeoGeometry geoGeometry)

6.3.1.7.21.3.5. checkGeometryType

protected boolean checkGeometryType(Feature feature)

6.3.1.7.21.3.6. checkPointOverlaps

protected boolean checkPointOverlaps(GeoPoint pt, double tolerance)

6.3.1.7.21.3.7. create

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

6.3.1.7.21.3.8. createFeature

public long createFeature(Feature feature)

6.3.1.7.21.3.9. createFeatureBatch

public void createFeatureBatch(Feature feature, SQLiteDatabase db)

6.3.1.7.21.3.10. createField

public void createField(Field field)

6.3.1.7.21.3.11. createFromGeoJson

public void createFromGeoJson(Uri uri, IProgressor progressor)

6.3.1.7.21.3.12. createFromGeoJson

public void createFromGeoJson(File path, IProgressor progressor)

6.3.1.7.21.3.13. createNewCache

protected IGeometryCache createNewCache()

6.3.1.7.21.3.14. cursorToFeature

public Feature cursorToFeature(Cursor cursor)

6.3.1.7.21.3.15. delete

public boolean delete()

6.3.1.7.21.3.16. delete

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

6.3.1.7.21.3.17. delete

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

6.3.1.7.21.3.18. deleteAddChanges

public int deleteAddChanges(long id)

Delete feature and add information to changes table for sync purposes

Parameters:
  • id – Feature identificator to delete
Returns:

Count of deleted features

6.3.1.7.21.3.19. deleteAllFeatures

public void deleteAllFeatures(IProgressor progressor)

6.3.1.7.21.3.20. deleteAllTempAttaches

public void deleteAllTempAttaches()

6.3.1.7.21.3.21. deleteAllTempAttachesFlags

public int deleteAllTempAttachesFlags()

6.3.1.7.21.3.22. deleteAllTempFeatures

public void deleteAllTempFeatures()

6.3.1.7.21.3.23. deleteAllTempFeaturesFlags

public int deleteAllTempFeaturesFlags()

6.3.1.7.21.3.24. deleteAllTemps

public void deleteAllTemps()

6.3.1.7.21.3.25. deleteAttach

protected void deleteAttach(String featureId, String attachId)

6.3.1.7.21.3.26. deleteAttachWithFlags

public int deleteAttachWithFlags(long featureId, long attachId)

6.3.1.7.21.3.27. deleteAttaches

protected void deleteAttaches(String featureId)

6.3.1.7.21.3.28. deleteInternal

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

6.3.1.7.21.3.29. fillFromGeoJson

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

6.3.1.7.21.3.30. fillFromGeoJson

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

6.3.1.7.21.3.31. fromJSON

public void fromJSON(JSONObject jsonObject)

6.3.1.7.21.3.32. getAttach

protected AttachItem getAttach(String featureId, String attachId)

6.3.1.7.21.3.33. getAttachMap

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

6.3.1.7.21.3.34. getContentUri

protected Uri getContentUri()

6.3.1.7.21.3.35. getCount

public int getCount()

6.3.1.7.21.3.36. getDefaultStyle

public Style getDefaultStyle()

6.3.1.7.21.3.37. getFeature

public Feature getFeature(long featureId)

6.3.1.7.21.3.38. getFeatureContentValues

protected ContentValues getFeatureContentValues(Feature feature)

6.3.1.7.21.3.39. getFeatureWithAttaches

public Feature getFeatureWithAttaches(long featureId)

6.3.1.7.21.3.40. getFieldByName

public Field getFieldByName(String name)

6.3.1.7.21.3.41. getFields

public List<Field> getFields()

6.3.1.7.21.3.42. getGeometryForId

public GeoGeometry getGeometryForId(long rowId)

6.3.1.7.21.3.43. getGeometryForId

public GeoGeometry getGeometryForId(long rowId, SQLiteDatabase db)

6.3.1.7.21.3.44. getGeometryForId

public GeoGeometry getGeometryForId(long rowId, int zoom)

6.3.1.7.21.3.45. getGeometryForId

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

6.3.1.7.21.3.46. getGeometryFromQuery

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

6.3.1.7.21.3.47. getGeometryType

public int getGeometryType()

6.3.1.7.21.3.48. getNewTempAttach

public AttachItem getNewTempAttach(Feature feature)

6.3.1.7.21.3.49. getNewTempFeature

public Feature getNewTempFeature()

6.3.1.7.21.3.50. getPreferences

public SharedPreferences getPreferences()

6.3.1.7.21.3.51. getStreamTypes

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

6.3.1.7.21.3.52. getStyleRule

protected IStyleRule getStyleRule()

6.3.1.7.21.3.53. getType

public String getType(Uri uri)

6.3.1.7.21.3.54. getUniqId

public long getUniqId()

6.3.1.7.21.3.55. hasAttachChanges

protected boolean hasAttachChanges(long featureId, long attachId)

6.3.1.7.21.3.56. hasAttachNotSyncFlag

public boolean hasAttachNotSyncFlag(long featureId, long attachId)

6.3.1.7.21.3.57. hasAttachTempFlag

public boolean hasAttachTempFlag(long featureId, long attachId)

6.3.1.7.21.3.58. hasFeatureAttaches

public boolean hasFeatureAttaches(long featureId)

6.3.1.7.21.3.59. hasFeatureChanges

protected boolean hasFeatureChanges(long featureId)

6.3.1.7.21.3.60. hasFeatureNotSyncFlag

public boolean hasFeatureNotSyncFlag(long featureId)

6.3.1.7.21.3.61. hasFeatureTempFlag

public boolean hasFeatureTempFlag(long featureId)

6.3.1.7.21.3.62. haveFeaturesNotSyncFlag

protected boolean haveFeaturesNotSyncFlag()

6.3.1.7.21.3.63. hideFeature

public void hideFeature(long featureId)

6.3.1.7.21.3.64. insert

protected long insert(ContentValues contentValues)

6.3.1.7.21.3.65. insert

public Uri insert(Uri uri, ContentValues contentValues)

6.3.1.7.21.3.66. insertAddChanges

public long insertAddChanges(ContentValues contentValues)

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

Parameters:
  • contentValues – Values to add
Returns:

New row identifiactor or -1

6.3.1.7.21.3.67. insertAttach

protected long insertAttach(String featureId, ContentValues contentValues)

6.3.1.7.21.3.68. insertAttachFile

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

6.3.1.7.21.3.69. insertInternal

protected long insertInternal(ContentValues contentValues)

6.3.1.7.21.3.70. insertTempAttach

protected Uri insertTempAttach(long featureId, AttachItem attachItem)

6.3.1.7.21.3.71. insertTempFeature

protected Uri insertTempFeature(Feature feature)

6.3.1.7.21.3.72. isChanges

public boolean isChanges()

6.3.1.7.21.3.73. isFeatureHidden

public boolean isFeatureHidden(long featureId)

6.3.1.7.21.3.74. isFieldsInitialized

public boolean isFieldsInitialized()

6.3.1.7.21.3.75. isLocked

public boolean isLocked()

6.3.1.7.21.3.76. isValid

public boolean isValid()

6.3.1.7.21.3.77. loadAttach

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

6.3.1.7.21.3.78. notifyDelete

public void notifyDelete(long rowId)

6.3.1.7.21.3.79. notifyDeleteAll

public void notifyDeleteAll()

6.3.1.7.21.3.80. notifyInsert

public void notifyInsert(long rowId)

6.3.1.7.21.3.81. notifyUpdate

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

6.3.1.7.21.3.82. notifyUpdateAll

public void notifyUpdateAll()

6.3.1.7.21.3.83. onUpgrade

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

6.3.1.7.21.3.84. openFile

public ParcelFileDescriptor openFile(Uri uri, String mode)

6.3.1.7.21.3.85. prepareGeometry

protected void prepareGeometry(ContentValues values)

6.3.1.7.21.3.86. 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<>[..]"

6.3.1.7.21.3.87. query

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

6.3.1.7.21.3.88. query

public List<Long> query(GeoEnvelope env)

6.3.1.7.21.3.89. queryFirstTempAttachFlags

public Cursor queryFirstTempAttachFlags()

6.3.1.7.21.3.90. queryFirstTempFeatureFlags

public Cursor queryFirstTempFeatureFlags()

6.3.1.7.21.3.91. queryInternal

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

6.3.1.7.21.3.92. rebuildCache

public void rebuildCache(IProgressor progressor)

6.3.1.7.21.3.93. reloadCache

protected synchronized void reloadCache()

6.3.1.7.21.3.94. reportError

protected void reportError(String error)

6.3.1.7.21.3.95. saveAttach

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

6.3.1.7.21.3.96. setAttachNotSyncFlag

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

6.3.1.7.21.3.97. setAttachTempFlag

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

6.3.1.7.21.3.98. setAttachesNotSyncFlag

public long setAttachesNotSyncFlag(long featureId, boolean flag)

6.3.1.7.21.3.99. setAttachesTempFlag

public long setAttachesTempFlag(long featureId, boolean flag)

6.3.1.7.21.3.100. setDefaultRenderer

protected void setDefaultRenderer()

6.3.1.7.21.3.101. setFeatureNotSyncFlag

public long setFeatureNotSyncFlag(long featureId, boolean flag)

6.3.1.7.21.3.102. setFeatureTempFlag

public long setFeatureTempFlag(long featureId, boolean flag)

6.3.1.7.21.3.103. setFeatureWithAttachesNotSyncFlag

public long setFeatureWithAttachesNotSyncFlag(Feature feature, boolean flag)

6.3.1.7.21.3.104. setFeatureWithAttachesNotSyncFlag

public long setFeatureWithAttachesNotSyncFlag(long featureId, boolean flag)

6.3.1.7.21.3.105. setFeatureWithAttachesTempFlag

public long setFeatureWithAttachesTempFlag(Feature feature, boolean flag)

6.3.1.7.21.3.106. setFeatureWithAttachesTempFlag

public long setFeatureWithAttachesTempFlag(long featureId, boolean flag)

6.3.1.7.21.3.107. setLocked

public void setLocked(boolean state)

6.3.1.7.21.3.108. setNewAttachId

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

6.3.1.7.21.3.109. setRenderer

protected void setRenderer(JSONObject jsonObject)

6.3.1.7.21.3.110. showAllFeatures

public void showAllFeatures()

6.3.1.7.21.3.111. showFeature

public void showFeature(long featureId)

6.3.1.7.21.3.112. swapFeaturesVisibility

public void swapFeaturesVisibility(long previousFeatureId, long featureId)

6.3.1.7.21.3.113. toJSON

public JSONObject toJSON()

6.3.1.7.21.3.114. toNGW

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

6.3.1.7.21.3.115. update

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

6.3.1.7.21.3.116. update

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

6.3.1.7.21.3.117. updateAddChanges

public int updateAddChanges(ContentValues values, long id)

Change feature and add information to changes table for sync purposes

Parameters:
  • values – New values to set
  • id – Feature identificator
Returns:

Count of changed features

6.3.1.7.21.3.118. updateAttach

public int updateAttach(Feature feature, AttachItem attachItem)

6.3.1.7.21.3.119. updateAttachWithFlags

public int updateAttachWithFlags(Feature feature, AttachItem attachItem)

6.3.1.7.21.3.120. updateFeature

public int updateFeature(Feature feature)

6.3.1.7.21.3.121. updateFeatureWithAttaches

public int updateFeatureWithAttaches(Feature feature)

6.3.1.7.21.3.122. updateFeatureWithAttachesWithFlags

public int updateFeatureWithAttachesWithFlags(Feature feature)

6.3.1.7.21.3.123. updateFeatureWithFlags

public int updateFeatureWithFlags(Feature feature)

6.3.1.7.21.3.124. updateUniqId

protected void updateUniqId(long id)