com.nextgis.maplib.api.ILayer Java Examples
The following examples show how to use
com.nextgis.maplib.api.ILayer.
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: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public int getVisibleTopLayerId() { for (int i = mLayers.size() - 1; i >= 0; i--) { ILayer layer = mLayers.get(i); if (layer instanceof LayerGroup) { LayerGroup layerGroup = (LayerGroup) layer; int visibleTopLayerId = layerGroup.getVisibleTopLayerId(); if (Constants.NOT_FOUND != visibleTopLayerId) { return visibleTopLayerId; } } else { if (layer.isValid() && layer instanceof ILayerView) { ILayerView layerView = (ILayerView) layer; if (layerView.isVisible()) { return layer.getId(); } } } } return Constants.NOT_FOUND; }
Example #2
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void fromJSON(JSONObject jsonObject) throws JSONException { super.fromJSON(jsonObject); clearLayers(); final JSONArray jsonArray = jsonObject.getJSONArray(JSON_LAYERS_KEY); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonLayer = jsonArray.getJSONObject(i); String sPath = jsonLayer.getString(JSON_PATH_KEY); File inFile = new File(getPath(), sPath); if (inFile.exists()) { ILayer layer = mLayerFactory.createLayer(mContext, inFile); if (null != layer && layer.load()) { addLayer(layer); } } } if (mOnAllLayersAddedListener != null) mOnAllLayersAddedListener.onAllLayersAdded(mLayers); }
Example #3
Source File: SyncAdapter.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected void sync( LayerGroup layerGroup, String authority, SyncResult syncResult) { for (int i = 0; i < layerGroup.getLayerCount(); i++) { if (isCanceled()) { return; } ILayer layer = layerGroup.getLayer(i); if (layer instanceof LayerGroup) { sync((LayerGroup) layer, authority, syncResult); } else if (layer instanceof INGWLayer) { INGWLayer ngwLayer = (INGWLayer) layer; String accountName = ngwLayer.getAccountName(); if (!mVersions.containsKey(accountName)) mVersions.put(accountName, NGWUtil.getNgwVersion(getContext(), accountName)); Pair<Integer, Integer> ver = mVersions.get(accountName); ngwLayer.sync(authority, ver, syncResult); } else if (layer instanceof TrackLayer) { ((TrackLayer) layer).sync(); } } }
Example #4
Source File: AttributesActivity.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void onStart() { super.onStart(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.NOTIFY_DELETE); intentFilter.addAction(Constants.NOTIFY_DELETE_ALL); registerReceiver(mReceiver, intentFilter); IGISApplication application = (IGISApplication) getApplication(); MapBase map = application.getMap(); if (null != map) { ILayer layer = map.getLayerById(mLayerId); if (null != layer && layer instanceof VectorLayer) { mLayer = (VectorLayer) layer; mTable.setAdapter(getAdapter()); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); toolbar.setSubtitle(mLayer.getName()); } else Toast.makeText(this, R.string.error_layer_not_inited, Toast.LENGTH_SHORT).show(); } }
Example #5
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public boolean isChanges() { for (ILayer layer : mLayers) { if (layer instanceof LayerGroup) { LayerGroup layerGroup = (LayerGroup) layer; if (layerGroup.isChanges()) { return true; } } else if (layer instanceof VectorLayer) { VectorLayer vectorLayer = (VectorLayer) layer; if (vectorLayer.isChanges()) { return true; } } } return false; }
Example #6
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public boolean haveFeaturesNotSyncFlag() { for (ILayer layer : mLayers) { if (layer instanceof LayerGroup) { LayerGroup layerGroup = (LayerGroup) layer; if (layerGroup.haveFeaturesNotSyncFlag()) { return true; } } else if (layer instanceof VectorLayer) { VectorLayer vectorLayer = (VectorLayer) layer; if (vectorLayer.haveFeaturesNotSyncFlag()) { return true; } } } return false; }
Example #7
Source File: MapEventSource.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
/** * Send layer added event to all listeners * * @param layer * A new layer */ @Override protected void onLayerAdded(ILayer layer) { super.onLayerAdded(layer); if (mListeners == null) { return; } Bundle bundle = new Bundle(); bundle.putInt(BUNDLE_ID_KEY, layer.getId()); bundle.putInt(BUNDLE_TYPE_KEY, EVENT_onLayerAdded); Message msg = new Message(); msg.setData(bundle); mHandler.sendMessage(msg); }
Example #8
Source File: MapEventSource.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
/** * Send layer changed event to all listeners * * @param layer * A changed layer */ @Override protected void onLayerChanged(ILayer layer) { super.onLayerChanged(layer); if (mListeners == null) { return; } Bundle bundle = new Bundle(); bundle.putInt(BUNDLE_ID_KEY, layer.getId()); bundle.putInt(BUNDLE_TYPE_KEY, EVENT_onLayerChanged); Message msg = new Message(); msg.setData(bundle); mHandler.sendMessage(msg); }
Example #9
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public int getVisibleLayerCount() { int visibleLayerCount = 0; for (int i = mLayers.size() - 1; i >= 0; i--) { ILayer layer = mLayers.get(i); if (layer instanceof LayerGroup) { LayerGroup layerGroup = (LayerGroup) layer; visibleLayerCount += layerGroup.getVisibleLayerCount(); } else { if (layer.isValid() && layer instanceof ILayerView) { ILayerView layerView = (ILayerView) layer; if (layerView.isVisible()) { ++visibleLayerCount; } } } } return visibleLayerCount; }
Example #10
Source File: MapContentProviderHelper.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public static void getLayersByAccount( LayerGroup layerGroup, String account, List<INGWLayer> layerList) { for (int i = 0; i < layerGroup.getLayerCount(); i++) { ILayer layer = layerGroup.getLayer(i); if (layer instanceof INGWLayer) { INGWLayer ngwLayer = (INGWLayer) layer; if (ngwLayer.getAccountName().equals(account)) { layerList.add(ngwLayer); } } if (layer instanceof LayerGroup) { getLayersByAccount((LayerGroup) layer, account, layerList); } } }
Example #11
Source File: SettingsFragment.java From android_gisapp with GNU General Public License v3.0 | 6 votes |
protected static void deleteLayers(Activity activity) { MainApplication app = (MainApplication) activity.getApplication(); for (int i = app.getMap().getLayerCount() - 1; i >= 0; i--) { ILayer layer = app.getMap().getLayer(i); if (!layer.getPath().getName().equals(MainApplication.LAYER_OSM) && !layer.getPath() .getName() .equals(MainApplication.LAYER_A) && !layer.getPath() .getName() .equals(MainApplication.LAYER_B) && !layer.getPath() .getName() .equals(MainApplication.LAYER_C) && !layer.getPath() .getName() .equals(MainApplication.LAYER_TRACKS)) { layer.delete(); } } try { ((MapContentProviderHelper) MapBase.getInstance()).getDatabase(false).execSQL("VACUUM"); } catch (SQLiteException e) { e.printStackTrace(); } }
Example #12
Source File: TMSRenderer.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public TMSRenderer(ILayer layer) { super(layer); mRasterPaint = new Paint(); mAntiAlias = true; mFilterBitmap = true; mDither = true; mContrast = 1; mBrightness = 0; mForceToGrayScale = false; mAlpha = 255; mRasterPaint.setAntiAlias(mAntiAlias); mRasterPaint.setFilterBitmap(mFilterBitmap); mRasterPaint.setDither(mDither); mRasterPaint.setAlpha(mAlpha); }
Example #13
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
/** * Get a list of specified type layers * * @param layerGroup * to inspect for layers * @param types * A layer type * @param layerList * A list to fill with find layers */ public static void getLayersByType( LayerGroup layerGroup, int types, List<ILayer> layerList) { for (int i = 0; i < layerGroup.getLayerCount(); i++) { ILayer layer = layerGroup.getLayer(i); if (0 != (types & layer.getType())) { layerList.add(layer); } if (layer instanceof LayerGroup) { getLayersByType((LayerGroup) layer, types, layerList); } } }
Example #14
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public static void getVectorLayersByType( LayerGroup layerGroup, int types, List<ILayer> layerList) { for (int i = 0; i < layerGroup.getLayerCount(); i++) { ILayer layer = layerGroup.getLayer(i); if (layer instanceof VectorLayer) { VectorLayer vectorLayer = (VectorLayer) layer; if (0 != (types & 1 << vectorLayer.getGeometryType())) { layerList.add(0, layer); } } if (layer instanceof LayerGroup) { getVectorLayersByType((LayerGroup) layer, types, layerList); } } }
Example #15
Source File: MainActivity.java From android_gisapp with GNU General Public License v3.0 | 6 votes |
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 #16
Source File: MainActivity.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
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 #17
Source File: MapFragment.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
public void onFinishChooseLayerDialog( int code, ILayer layer) { VectorLayer vectorLayer = (VectorLayer) layer; if (layer == null) return; // TODO toast? if (mSelectedLayer != null) mSelectedLayer.setLocked(false); mSelectedLayer = vectorLayer; mEditLayerOverlay.setSelectedLayer(vectorLayer); if (code == ADD_CURRENT_LOC) { if (layer instanceof ILayerUI) { IVectorLayerUI layerUI = (IVectorLayerUI) layer; layerUI.showEditForm(mActivity, Constants.NOT_FOUND, null); } } else if (code == EDIT_LAYER) { setMode(MODE_SELECT_ACTION); } else if (code == ADD_GEOMETRY_BY_WALK) { mEditLayerOverlay.newGeometryByWalk(); setMode(MODE_EDIT_BY_WALK); } else if (code == ADD_POINT_BY_TAP) { createPointFromOverlay(); } }
Example #18
Source File: MapFragment.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
protected void addCurrentLocation() { //show select layer dialog if several layers, else start default or custom form List<ILayer> layers = mMap.getVectorLayersByType( GeoConstants.GTMultiPointCheck | GeoConstants.GTPointCheck); layers = removeHideLayers(layers); if (layers.isEmpty()) { Toast.makeText( mActivity, getString(R.string.warning_no_edit_layers), Toast.LENGTH_LONG) .show(); } else if (layers.size() == 1) { //open form ILayer vectorLayer = layers.get(0); if (vectorLayer instanceof ILayerUI) { mSelectedLayer = (VectorLayer) vectorLayer; mEditLayerOverlay.setSelectedLayer(mSelectedLayer); IVectorLayerUI vectorLayerUI = (IVectorLayerUI) vectorLayer; vectorLayerUI.showEditForm(mActivity, Constants.NOT_FOUND, null); Toast.makeText( mActivity, String.format(getString(R.string.edit_layer), vectorLayer.getName()), Toast.LENGTH_SHORT).show(); } else { Toast.makeText( mActivity, getString(R.string.warning_no_edit_layers), Toast.LENGTH_LONG).show(); } } else { if (isDialogShown()) return; //open choose dialog mChooseLayerDialog = new ChooseLayerDialog(); mChooseLayerDialog.setLayerList(layers) .setCode(ADD_CURRENT_LOC) .setTitle(getString(R.string.choose_layers)) .setTheme(mActivity.getThemeId()) .show(mActivity.getSupportFragmentManager(), "choose_layer"); } }
Example #19
Source File: MapFragment.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
protected List<ILayer> removeHideLayers(List<ILayer> layerList) { for (int i = 0; i < layerList.size(); i++) { ILayerView layerView = (ILayerView) layerList.get(i); if (null != layerView) { if (!layerView.isVisible()) { layerList.remove(i); i--; } } } return layerList; }
Example #20
Source File: MapFragment.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
protected void addGeometryByWalk() { //show select layer dialog if several layers, else start default or custom form List<ILayer> layers = mMap.getVectorLayersByType(GeoConstants.GTLineStringCheck | GeoConstants.GTPolygonCheck | GeoConstants.GTMultiLineStringCheck | GeoConstants.GTMultiPolygonCheck); layers = removeHideLayers(layers); if (layers.isEmpty()) { Toast.makeText(mActivity, getString(R.string.warning_no_edit_layers), Toast.LENGTH_LONG).show(); } else if (layers.size() == 1) { //open form VectorLayer layer = (VectorLayer) layers.get(0); mSelectedLayer = layer; mEditLayerOverlay.setSelectedLayer(layer); mEditLayerOverlay.newGeometryByWalk(); setMode(MODE_EDIT_BY_WALK); Toast.makeText(mActivity, String.format(getString(R.string.edit_layer), layer.getName()), Toast.LENGTH_SHORT).show(); } else { if (isDialogShown()) return; //open choose edit layer dialog mChooseLayerDialog = new ChooseLayerDialog(); mChooseLayerDialog.setLayerList(layers) .setCode(ADD_GEOMETRY_BY_WALK) .setTitle(getString(R.string.choose_layers)) .setTheme(mActivity.getThemeId()) .show(mActivity.getSupportFragmentManager(), "choose_layer"); } }
Example #21
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean save() { synchronized (this) { for (ILayer layer : mLayers) { layer.save(); } } return super.save(); }
Example #22
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public void clearLayers() { for (ILayer layer : mLayers) { if (layer instanceof LayerGroup) { ((LayerGroup) layer).clearLayers(); } } mLayers.clear(); }
Example #23
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public JSONObject toJSON() throws JSONException { JSONObject rootConfig = super.toJSON(); JSONArray jsonArray = new JSONArray(); rootConfig.put(JSON_LAYERS_KEY, jsonArray); for (ILayer layer : mLayers) { JSONObject layerObject = new JSONObject(); layerObject.put(JSON_PATH_KEY, layer.getPath().getName()); jsonArray.put(layerObject); } return rootConfig; }
Example #24
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean delete() { for (ILayer layer : mLayers) { layer.setParent(null); layer.delete(); } return super.delete(); }
Example #25
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setVisible(boolean visible) { for (ILayer layer : mLayers) { if (layer instanceof ILayerView) { ILayerView layerView = (ILayerView) layer; layerView.setVisible(visible); } } }
Example #26
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean isVisible() { for (ILayer layer : mLayers) { if (layer instanceof ILayerView) { ILayerView layerView = (ILayerView) layer; if (layerView.isVisible()) { return true; } } } return false; }
Example #27
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void cancelDraw() { for (ILayer layer : mLayers) { if (layer instanceof IRenderer) { IRenderer renderer = (IRenderer) layer; renderer.cancelDraw(); } } }
Example #28
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void runDraw(GISDisplay display) { if (null != display && mDisplay != display) { mDisplay = display; } if (mLayers.size() == 0) { return; } //synchronized (this) { for (ILayer layer : mLayers) { if (Thread.currentThread().isInterrupted()) { break; } if (layer instanceof LayerGroup) { LayerGroup layerGroup = (LayerGroup) layer; layerGroup.runDraw(mDisplay); } else { if (layer.isValid() && layer instanceof ILayerView) { ILayerView layerView = (ILayerView) layer; if (layerView.isVisible() && layer instanceof IRenderer && mDisplay.getZoomLevel() <= layerView.getMaxZoom() && mDisplay.getZoomLevel() >= layerView.getMinZoom()) { // Log.d(Constants.TAG, "Layer Draw Index: " + mLayerDrawIndex); IRenderer renderer = (IRenderer) layer; renderer.runDraw(mDisplay); } } } } //} }
Example #29
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public int removeLayer(ILayer layer) { synchronized (this) { int result = mLayers.size() - 1; if (layer != null) { result = mLayers.indexOf(layer); onLayerDeleted(layer.getId()); } return result; } }
Example #30
Source File: LayerGroup.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public void moveLayer( int newPosition, ILayer layer) { if (layer != null) { synchronized (this) { mLayers.remove(layer); mLayers.add(newPosition, layer); } onLayersReordered(); } }