qq_35980546 于 2017.09.19 08:22 提问

1个回答

code68   2017.09.19 08:34

DatasourceConnectionInfo datasourceConnnectionInfo = new DatasourceConnectionInfo();
datasourceConnnectionInfo.EngineType = EngineType.UDB;
datasourceConnnectionInfo.Server = ":memory:"
datasourceConnnectionInfo.Alias = "mdata";

DatasetVector datasetvectorgrid = workspace.Datasources["mdata"].Datasets["mapgrid"] as DatasetVector;
Recordset recordset = datasetvectorgrid.GetRecordset(false, CursorType.Dynamic);
Rectangle2D maprectangle = new Rectangle2D();
maprectangle = mapcontrol.Map.ViewBounds;
double distancex = (maprectangle.Right - maprectangle.Left) / 10;
double distancey = (maprectangle.Top - maprectangle.Bottom) / 9;
Point2D point2d = new Point2D();
rectangles = new Rectangle2D[100];
Array .Clear (rectangles ,0, rectangles .Length );
int count = 0;
For (int j = 0; j <= 8; j++)
{
for (int i = 0; i <= 9; i++)
{
point2d.X = maprectangle.Left + distancex * i;
point2d.Y = maprectangle.Bottom + distancey * j;
Rectangle2D rectangle = new Rectangle2D(point2d, distancex, distancey);
rectangles[count] = rectangle;
count++;
GeoRectangle georectangle = new GeoRectangle(rectangle, 0);
GeoStyle style = Setgeostyle();
georectangle.Style = style;
recordset.AddNew(georectangle);
recordset.Update();
}
}

//检查是否包含;
private void IsCanContain()
{
//聚合点数据集；
DatasetVector datasetvectorgrid = workspace.Datasources["mdata"].Datasets["point"] as DatasetVector;
Recordset recordsetpoint = datasetvectorgrid.GetRecordset(false, CursorType.Dynamic);
//原始点数据集；
DatasetVector datasetvectorpoint = workspace.Datasources[0].Datasets["POIP"] as DatasetVector;

Recordset recordset = datasetvectorpoint.GetRecordset(false, CursorType.Static);
//临时单个聚合对象点
DatasetVector datasetvetortpoint = workspace .Datasources ["mdata"].Datasets ["tpoint"] as DatasetVector ;
recordsetpoint.DeleteAll();
Point2D[] point2ds = new Point2D[recordset.RecordCount];
int pointitem = 0;
for (int i = 0; i < 100; i++)
{
int count = 0;
Rectangle2D rectangle = rectangles[i];

recordset.MoveFirst();
Recordset rectangleitemrecordset = datasetvetortpoint.GetRecordset(false, CursorType.Dynamic);
for (int j = 0; j < recordset.RecordCount; j++)
{
Geometry geometry = recordset.GetGeometry();

GeoPoint geopoint = geometry as GeoPoint ;
Point2D point2d = new Point2D (geopoint .X ,geopoint .Y );
if (rectangle .Contains (point2d ))
{
if (Array.IndexOf(point2ds, point2d) == -1)
{
count++;
point2ds[pointitem] = point2d;
pointitem++;
GeoPoint itemgeopoint = new GeoPoint(point2d);
rectangleitemrecordset.AddNew(itemgeopoint);
rectangleitemrecordset.Update();
}
}
recordset.MoveNext();
}

qq_35980546 不行,生成不了图片,
6 个月之前 回复
qq_35980546 谢谢大哥,我看一下
6 个月之前 回复