Java Code Examples for com.nextgis.maplib.map.MapBase#getLayer()

The following examples show how to use com.nextgis.maplib.map.MapBase#getLayer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 6 votes vote down vote up
void testDelete()
{
    IGISApplication application = (IGISApplication) getApplication();
    MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for (int i = 0; i < map.getLayerCount(); i++) {
        ILayer layer = map.getLayer(i);
        if (layer instanceof NGWVectorLayer) {
            ngwVectorLayer = (NGWVectorLayer) layer;
        }
    }
    if (null != ngwVectorLayer) {
        Uri uri = Uri.parse(
                "content://" + AppSettingsConstants.AUTHORITY + "/" +
                ngwVectorLayer.getPath().getName());
        Uri deleteUri = ContentUris.withAppendedId(uri, 27);
        int result = getContentResolver().delete(deleteUri, null, null);
        if(Constants.DEBUG_MODE){
            if (result == 0) {
                Log.d(TAG, "delete failed");
            } else {
                Log.d(TAG, "" + result);
            }
        }
    }
}
 
Example 2
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
void testSync()
{
    IGISApplication application = (IGISApplication) getApplication();
    MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer;
    for (int i = 0; i < map.getLayerCount(); i++) {
        ILayer layer = map.getLayer(i);
        if (layer instanceof NGWVectorLayer) {
            ngwVectorLayer = (NGWVectorLayer) layer;
            Pair<Integer, Integer> ver = NGWUtil.getNgwVersion(this, ngwVectorLayer.getAccountName());
            ngwVectorLayer.sync(application.getAuthority(), ver, new SyncResult());
        }
    }
}
 
Example 3
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 4 votes vote down vote up
void testUpdate()
{
    //test sync
    IGISApplication application = (IGISApplication) getApplication();
    MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for (int i = 0; i < map.getLayerCount(); i++) {
        ILayer layer = map.getLayer(i);
        if (layer instanceof NGWVectorLayer) {
            ngwVectorLayer = (NGWVectorLayer) layer;
        }
    }
    if (null != ngwVectorLayer) {
        Uri uri = Uri.parse(
                "content://" + AppSettingsConstants.AUTHORITY + "/" +
                ngwVectorLayer.getPath().getName());
        Uri updateUri = ContentUris.withAppendedId(uri, 29);
        ContentValues values = new ContentValues();
        values.put("width", 4);
        values.put("azimuth", 8.0);
        values.put("status", "test4");
        values.put("temperatur", -10);
        values.put("name", "xxx");

        Calendar calendar = new GregorianCalendar(2014, Calendar.JANUARY, 23);
        values.put("datetime", calendar.getTimeInMillis());
        try {
            GeoPoint pt = new GeoPoint(67, 65);
            pt.setCRS(CRS_WGS84);
            pt.project(CRS_WEB_MERCATOR);
            GeoMultiPoint mpt = new GeoMultiPoint();
            mpt.add(pt);
            values.put(Constants.FIELD_GEOM, mpt.toBlob());
        } catch (IOException e) {
            e.printStackTrace();
        }
        int result = getContentResolver().update(updateUri, values, null, null);
        if(Constants.DEBUG_MODE){
            if (result == 0) {
                Log.d(TAG, "update failed");
            } else {
                Log.d(TAG, "" + result);
            }
        }
    }
}
 
Example 4
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 4 votes vote down vote up
void testInsert()
{
    //test sync
    IGISApplication application = (IGISApplication) getApplication();
    MapBase map = application.getMap();
    NGWVectorLayer ngwVectorLayer = null;
    for (int i = 0; i < map.getLayerCount(); i++) {
        ILayer layer = map.getLayer(i);
        if (layer instanceof NGWVectorLayer) {
            ngwVectorLayer = (NGWVectorLayer) layer;
        }
    }
    if (null != ngwVectorLayer) {
        Uri uri = Uri.parse(
                "content://" + AppSettingsConstants.AUTHORITY + "/" +
                        ngwVectorLayer.getPath().getName());
        ContentValues values = new ContentValues();
        //values.put(VectorLayer.FIELD_ID, 26);
        values.put("width", 1);
        values.put("azimuth", 2.0);
        values.put("status", "grot");
        values.put("temperatur", -13);
        values.put("name", "get");

        Calendar calendar = new GregorianCalendar(2015, Calendar.JANUARY, 23);
        values.put("datetime", calendar.getTimeInMillis());

        try {
            GeoPoint pt = new GeoPoint(37, 55);
            pt.setCRS(CRS_WGS84);
            pt.project(CRS_WEB_MERCATOR);
            GeoMultiPoint mpt = new GeoMultiPoint();
            mpt.add(pt);
            values.put(Constants.FIELD_GEOM, mpt.toBlob());
        } catch (IOException e) {
            e.printStackTrace();
        }
        Uri result = getContentResolver().insert(uri, values);
        if(Constants.DEBUG_MODE){
            if (result == null) {
                Log.d(TAG, "insert failed");
            } else {
                Log.d(TAG, result.toString());
            }
        }
    }
}