您好,我使用的是Demo的数据源,现在是想添加线条,但是addNew()返回值为false,求告知!谢谢
m_mapControl = m_mapview.getMapControl();
m_workspace = new Workspace();
m_mapControl.getMap().setWorkspace(m_workspace);
DatasourceConnectionInfo dsInfo = new DatasourceConnectionInfo();
dsInfo.setServer(sdcard + "/SampleData/GeometryInfo/World.udb");
dsInfo.setEngineType(EngineType.UDB);
Datasource datasource = m_workspace.getDatasources().open(dsInfo);
DatasetVector dataset = null;
if (datasource != null) {
dataset = (DatasetVector) datasource.getDatasets().get("Capitals");
m_mapControl.getMap().close();
m_mapControl.getMap().getLayers().add(dataset, true);
m_mapControl.getMap().viewEntire();
Point2Ds point2Ds = new Point2Ds();
Point2D point2D = new Point2D(108.888398, 34.228818);
point2Ds.add(point2D);
prjCoordSys = m_mapControl.getMap().getPrjCoordSys();
boolean forward = CoordSysTranslator.forward(point2Ds, prjCoordSys);
m_mapControl.getMap().setCenter(point2Ds.getItem(0));
m_mapControl.getMap().setScale(1 / 57373.046875);
m_mapControl.getMap().refresh();
}
if (dataset != null) {
Recordset recordset = dataset.getRecordset(false, CursorType.DYNAMIC);
GeoPoint geoPoint = new GeoPoint(new Point2D(7056.451, 34690.675));
boolean b = recordset.addNew(geoPoint);
recordset.update();
Point2Ds point2Ds = new Point2Ds();
point2Ds.add(new Point2D(7056.451, 34690.675));
point2Ds.add(new Point2D(6254.780, 54220.603));
// boolean forward = CoordSysTranslator.forward(point2Ds, prjCoordSys);
GeoLine geoLine = new GeoLine(point2Ds);
GeoStyle geoStyle_L = new GeoStyle();
geoStyle_L.setLineColor(new Color(255, 0, 0));
geoStyle_L.setLineSymbolID(15);
geoStyle_L.setLineWidth(1.0);
geoLine.setStyle(geoStyle_L);
b = recordset.addNew(geoLine);
LogUtil.i("b: " + b);
if (b) {
recordset.update();
m_mapControl.getMap().setViewBounds(recordset.getBounds());
m_mapControl.getMap().refresh();
}
recordset.dispose();
}