首页 / 浏览问题 / 云GIS / 问题详情
iobject数据集追加记录,iserver设置了自动刷新,地图数据不更新
1EXP 2021年09月09日
public static void addPointRecordSet(String datasetName, double x, double y, HashMap<String, Object> map) {
    //创建工作空间对象
    Workspace workspace = new Workspace();
    //设置工作空间连接信息
    workspace.open(workspaceConnectionInfo);
    //获取工作空间数据源
    Datasource datasource = workspace.getDatasources().get(datasourceName);
    Datasets datasets = datasource.getDatasets();
    DatasetVector dataset = (DatasetVector) datasets.get(datasetName);
    Recordset recordset = dataset.getRecordset(false, CursorType.DYNAMIC);

    //转换坐标系
    Point2Ds point2Ds = new Point2Ds();
    Point2D point2D = new Point2D();
    point2D.setX(x);
    point2D.setY(y);
    point2Ds.add(point2D);
    PrjCoordSys prjCoordSys = new PrjCoordSys(PrjCoordSysType.PCS_WGS_1984_WEB_MERCATOR);
    CoordSysTranslator.forward(point2Ds,prjCoordSys);
    Point2D item = point2Ds.getItem(0);

    recordset.edit();
    //将数据追加到数据集中
    GeoPoint geoPoint = new GeoPoint(item);
    recordset.addNew(geoPoint, map);
    recordset.update();
    //关闭资源
    datasource.close();
    workspace.close();
    workspace.dispose();
}

数据集追加成功,但是地图没有自动更新

使用desktop查看地图数据已更更新

iserverr没有更新

1个回答

您那边查看iServer中对应的数据集是否追加成功?这个需要您将您的工作空间重现刷新下
2,243EXP 2021年09月09日
我试了 数据追加上了,但是地图有问题,新追加的点没有显示,但是框选查询能查询处数据,删掉的点,地图上还显示,但是框选没有数据了

有什么办法解决这个问题么
发布问题的也是我,刚用邮箱登的
我也试了刷新工作空间通过rest api,但是数据服务和地图服务全都没有了
try
        {
            String json = "{\"workspaceConnectionInfo\": \"" + "server=ip;username=xx;password=xxx;type=SQL;database=test;name=test;driver=SQL Server"
                    + "\",\"isForce\": \"" + "true" + "\",\"datasets\": " + "{\"test\": " + "[\"\"]" + "}}";
            out.println(json);
            URL url = null;
            try {
                url = new URL("http://ip:8090/iserver/manager/workspaces/workspacereload.rjson?token=hTBRwlH71Q0jUpjx8gnoVK8PNlsvmKEFQbSYBLRRiDcKCpFTKEGbLK73YA.." );
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            HttpURLConnection connection = (HttpURLConnection) url.openConnection( );
            connection.setDoInput( true );
            connection.setDoOutput( true );
            try {
                connection.setRequestMethod( "POST" );
            } catch (ProtocolException e) {
                e.printStackTrace();
            }
            connection.setUseCaches( false );
            connection.setInstanceFollowRedirects( true );
            connection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );
            connection.connect();
            DataOutputStream out = new DataOutputStream(connection.getOutputStream());
            out.writeBytes(json);
            out.flush();
            out.close();

            BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream()));
            String lines;
            StringBuffer sbf = new StringBuffer();
            while (( lines = reader.readLine()) != null )
            {
                lines = new String( lines.getBytes(), "utf-8" );
                sbf.append(lines);
            }
            System.out.println( "//" + sbf + "//" );

            reader.close();
            connection.disconnect();


        } catch ( MalformedURLException e )
        {
            e.printStackTrace( );
        } catch ( IOException e )
        {
            e.printStackTrace( );
        }

用这段代码刷新工作空间后,地图服务和数据服务就全没了

不知道是什么原因

您那边iServer控制台和日志中有记录错误生成吗?
我看了后台是没有报错
...