Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I tried with a Ogr Layer and with a Ogr Vector Datasource, this last one is what I show you.
- ...
- import com.nutiteq.datasources.vector.OGRVectorDataSource;
- import com.nutiteq.layers.vector.OgrLayer;
- ...
- private void doRestrictedZones() {
- // TODO Auto-generated method stub
- mDrawerLayout.closeDrawers();
- Class<?> activityToRun = (Class<?>) WmsMapActivity.class;
- FilePicker activityInstance = null;
- try {
- activityInstance = (FilePicker) activityToRun.newInstance();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- FilePickerActivity.setFileSelectMessage(activityInstance.getFileSelectMessage());
- FilePickerActivity.setFileDisplayFilter(activityInstance.getFileFilter());
- Intent intent = new Intent(WmsMapActivity.this, FilePickerActivity.class);
- Bundle bundle = new Bundle();
- bundle.putString("class", "WmsMapActivity");
- intent.putExtras(bundle);
- startActivityForResult(intent, PICK_FILE );
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
- switch(requestCode){
- case PICK_FILE:
- if (resultCode == RESULT_OK ) {
- // read filename from extras
- //Bundle b = intent.getExtras();;//getIntent().getExtras();
- String file = intent.getStringExtra("selectedFile");
- createStyleSets();
- if (file.endsWith(".db") || file.endsWith(".sqlite") || file.endsWith(".spatialite")) {
- Log.i("TAG", "WmsMapActivity::onActivityResult:: NOT Vector File");
- } else {
- addOgrVectorDataSourceLayer(mapLayer.getProjection(), file, null, Color.BLUE);
- }
- }
- break;
- }
- }
- // JNI Java Part
- private void addOgrVectorDataSourceLayer(Projection proj, String dbPath, String table, int color) {
- OGRVectorDataSource dataSource;
- try {
- dataSource = new OGRVectorDataSource(proj, dbPath, table) {
- @Override
- protected Label createLabel(Map<String, String> userData) {
- return WmsMapActivity.this.createLabel(userData);
- }
- @Override
- protected StyleSet<PointStyle> createPointStyleSet(Map<String, String> userData, int zoom) {
- return pointStyleSet;
- }
- @Override
- protected StyleSet<LineStyle> createLineStyleSet(Map<String, String> userData, int zoom) {
- return lineStyleSet;
- }
- @Override
- protected StyleSet<PolygonStyle> createPolygonStyleSet(Map<String, String> userData, int zoom) {
- return polygonStyleSet;
- }
- };
- } catch (IOException e) {
- Log.e("TAG",e.getLocalizedMessage());
- //Toast.makeText(this, "ERROR "+e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
- return;
- }
- dataSource.setMaxElements(MAX_ELEMENTS);
- GeometryLayer ogrLayer = new GeometryLayer(dataSource);
- mapView.getLayers().addLayer(ogrLayer);
- Envelope extent = ogrLayer.getDataExtent();
- mapView.setBoundingBox(new Bounds(extent.minX, extent.maxY, extent.maxX, extent.minY), false);
- }
- //*******************************************************************************************************//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement