Java Code Examples for com.nextgis.maplib.util.FileUtil#readFromFile()
The following examples show how to use
com.nextgis.maplib.util.FileUtil#readFromFile() .
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: FormBuilderModifyAttributesActivity.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case RESELECT_ROW: if (mMeta != null && mMeta.exists()) { try { String metaString = FileUtil.readFromFile(mMeta); JSONObject metaJson = new JSONObject(metaString); metaJson.remove(JSON_KEY_LIST_SAVED_KEY); FileUtil.writeToFile(mMeta, metaJson.toString()); refreshActivityView(); } catch (JSONException | IOException ignored) {} } return true; default: return super.onOptionsItemSelected(item); } }
Example 2
Source File: LayerUtil.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
public static ArrayList<String> fillLookupTableIds(File path) throws IOException, JSONException { String formText = FileUtil.readFromFile(path); JSONArray formJson = new JSONArray(formText); ArrayList<String> lookupTableIds = new ArrayList<>(); for (int i = 0; i < formJson.length(); i++) { JSONObject element = formJson.getJSONObject(i); if (ConstantsUI.JSON_COMBOBOX_VALUE.equals(element.optString(Constants.JSON_TYPE_KEY))) { element = element.getJSONObject(ConstantsUI.JSON_ATTRIBUTES_KEY); if (element.has(ConstantsUI.JSON_NGW_ID_KEY)) if (element.getLong(ConstantsUI.JSON_NGW_ID_KEY) != -1) lookupTableIds.add(element.getLong(ConstantsUI.JSON_NGW_ID_KEY) + ""); } } return lookupTableIds; }
Example 3
Source File: VectorLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected Map<String, AttachItem> loadAttach(String featureId) { File attachFolder = new File(mPath, featureId); File meta = new File(attachFolder, META); try { String metaContent = FileUtil.readFromFile(meta); JSONArray jsonArray = new JSONArray(metaContent); Map<String, AttachItem> attach = new HashMap<>(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonValue = jsonArray.getJSONObject(i); AttachItem attachItem = new AttachItem(); attachItem.fromJSON(jsonValue); attach.put(attachItem.getAttachId(), attachItem); } return attach; } catch (IOException | JSONException e) { // e.printStackTrace(); } return null; }
Example 4
Source File: LayerFillService.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean execute(IProgressor progressor) { try { VectorLayer vectorLayer = (VectorLayer) mLayer; if (null == vectorLayer) return false; File meta = new File(mPath.getParentFile(), NGFP_META); if (meta.exists()) { String jsonText = FileUtil.readFromFile(meta); JSONObject metaJson = new JSONObject(jsonText); //read fields List<Field> fields = NGWUtil.getFieldsFromJson(metaJson.getJSONArray(NGWUtil.NGWKEY_FIELDS)); //read geometry type String geomTypeString = metaJson.getString("geometry_type"); int geomType = GeoGeometryFactory.typeFromString(geomTypeString); vectorLayer.create(geomType, fields); if (GeoJSONUtil.isGeoJsonHasFeatures(mPath)) { //read SRS -- not need as we will be fill layer with 3857 JSONObject srs = metaJson.getJSONObject(NGWUtil.NGWKEY_SRS); int nSRS = srs.getInt(NGWUtil.NGWKEY_ID); vectorLayer.fillFromGeoJson(mPath, nSRS, progressor); } } else vectorLayer.createFromGeoJson(mPath, progressor); // should never get there } catch (IOException | JSONException | SQLiteException | NGException | ClassCastException e) { e.printStackTrace(); setError(e, progressor); notifyError(mProgressMessage); return false; } if (mDeletePath) FileUtil.deleteRecursive(mPath); return true; }
Example 5
Source File: Table.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean load() { try { JSONObject jsonObject = new JSONObject(FileUtil.readFromFile(getFileName())); fromJSON(jsonObject); } catch (JSONException | IOException | SQLiteException e) { e.printStackTrace(); return false; } return true; }
Example 6
Source File: VectorLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected IStyleRule getStyleRule() { try { JSONObject jsonObject = new JSONObject(FileUtil.readFromFile(getFileName())); jsonObject = jsonObject.getJSONObject(JSON_RENDERERPROPS_KEY); jsonObject = jsonObject.getJSONObject(JSON_STYLE_RULE_KEY); FieldStyleRule rule = new FieldStyleRule(this); rule.fromJSON(jsonObject); return rule; } catch (JSONException | IOException e) { e.printStackTrace(); } return null; }
Example 7
Source File: LayerFactoryUI.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
public ILayer createLayer( Context context, File path) { File config_file = new File(path, CONFIG); ILayer layer = null; try { String sData = FileUtil.readFromFile(config_file); JSONObject rootObject = new JSONObject(sData); int nType = rootObject.getInt(JSON_TYPE_KEY); switch (nType) { case LAYERTYPE_REMOTE_TMS: layer = new RemoteTMSLayerUI(context, path); break; case LAYERTYPE_NGW_RASTER: layer = new NGWRasterLayerUI(context, path); break; case LAYERTYPE_NGW_VECTOR: layer = new NGWVectorLayerUI(context, path); break; case LAYERTYPE_NGW_WEBMAP: layer = new NGWWebMapLayerUI(context, path); break; case LAYERTYPE_LOCAL_VECTOR: layer = new VectorLayerUI(context, path); break; case LAYERTYPE_LOCAL_TMS: layer = new LocalTMSLayerUI(context, path); break; case LAYERTYPE_GROUP: layer = new LayerGroupUI(context, path, this); break; case LAYERTYPE_TRACKS: layer = new TrackLayerUI(context, path); break; case LAYERTYPE_LOOKUPTABLE: layer = new NGWLookupTable(context, path); // TODO: 26.07.15 Do we need UI for this? break; } } catch (IOException | JSONException e) { Log.d(TAG, e.getLocalizedMessage()); } return layer; }
Example 8
Source File: LayerFactory.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
public ILayer createLayer( Context context, File path) { File config_file = new File(path, CONFIG); ILayer layer = null; try { String sData = FileUtil.readFromFile(config_file); JSONObject rootObject = new JSONObject(sData); int nType = rootObject.getInt(JSON_TYPE_KEY); switch (nType) { case LAYERTYPE_REMOTE_TMS: layer = new RemoteTMSLayer(context, path); break; case LAYERTYPE_NGW_RASTER: layer = new NGWRasterLayer(context, path); break; case LAYERTYPE_NGW_VECTOR: layer = new NGWVectorLayer(context, path); break; case LAYERTYPE_NGW_WEBMAP: layer = new NGWWebMapLayer(context, path); break; case LAYERTYPE_LOCAL_VECTOR: layer = new VectorLayer(context, path); break; case LAYERTYPE_LOCAL_TMS: layer = new LocalTMSLayer(context, path); break; case LAYERTYPE_GROUP: layer = new LayerGroup(context, path, this); break; case LAYERTYPE_TRACKS: layer = new TrackLayer(context, path); break; case LAYERTYPE_LOOKUPTABLE: layer = new NGWLookupTable(context, path); break; } } catch (IOException | JSONException e) { Log.d(TAG, e.getLocalizedMessage()); } return layer; }