public void RenderFeatureTest() { IFeatureProvider provider = DataSourceHelper.CreateGeometryDatasource(_factories.GeoFactory); TestVectorRenderer vectorRenderer = new TestVectorRenderer(); BasicGeometryRenderer2D <RenderObject> geometryRenderer = new BasicGeometryRenderer2D <RenderObject>(vectorRenderer); FeatureDataTable features = new FeatureDataTable(_factories.GeoFactory); IExtents extents = provider.GetExtents(); FeatureQueryExpression query = new FeatureQueryExpression(extents.ToGeometry(), SpatialOperation.Intersects, provider); features.Merge(provider.ExecuteFeatureQuery(query) as IEnumerable <IFeatureDataRecord>, provider.GeometryFactory); foreach (FeatureDataRow feature in features) { IGeometry g = feature.Geometry; List <RenderObject> renderedObjects = new List <RenderObject>(geometryRenderer.RenderFeature(feature)); for (Int32 i = 0; i < renderedObjects.Count; i++) { RenderObject ro = renderedObjects[i]; } } }
public void RenderingPointsGeometriesWithGdiVectorRendererProducesCorrectGdiBitmaps() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable <GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); Int32 geoIndex = 0; foreach (GdiRenderObject ro in renderedObjects) { IGeometry g = record.Geometry; if (g is IMultiPoint) { IMultiPoint mp = g as IMultiPoint; Assert.AreEqual(mp[geoIndex][Ordinates.X], ro.Bounds.Location.X, _e); Assert.AreEqual(mp[geoIndex][Ordinates.Y], ro.Bounds.Location.Y, _e); geoIndex++; } else if (g is IPoint) { IPoint p = g as IPoint; Assert.AreEqual(p[Ordinates.X], ro.Bounds.Location.X, _e); Assert.AreEqual(p[Ordinates.Y], ro.Bounds.Location.Y, _e); } } } } }
public void RenderingPolygonsWithGdiVectorRendererProducesCorrectGdiPaths() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable <GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); foreach (GdiRenderObject ro in renderedObjects) { IGeometry g = record.Geometry; if (g is IPolygon) { IPolygon p = g as IPolygon; using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(p.ExteriorRing.Coordinates.Count, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < p.ExteriorRing.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)p.ExteriorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } foreach (ILineString interiorRing in p.InteriorRings) { iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(interiorRing.PointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < interiorRing.PointCount; vertexIndex++) { ICoordinate v = interiorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } } } else if (g is IMultiPolygon) { IMultiPolygon mp = g as IMultiPolygon; using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { foreach (IPolygon p in (IEnumerable <IPolygon>)mp) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Int32 exteriorPointCount = p.ExteriorRing.PointCount; Assert.AreEqual(exteriorPointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < exteriorPointCount; vertexIndex++) { ICoordinate v = p.ExteriorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } foreach (ILineString interiorRing in p.InteriorRings) { iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(interiorRing.PointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < interiorRing.PointCount; vertexIndex++) { ICoordinate v = interiorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } } } } } } } }
public void RenderingLinesWithGdiVectorRendererProducesCorrectGdiPaths() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D <GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D <GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable <GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); Int32 geoIndex = 0; IGeometry g = record.Geometry; foreach (GdiRenderObject ro in renderedObjects) { using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); if (g is ILineString) { Assert.IsFalse(isClosed); ILineString ls = g as ILineString; Assert.AreEqual(1, iter.SubpathCount); for (Int32 vertexIndex = 0; vertexIndex < ls.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)ls.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } else if (g is IMultiLineString) { Assert.IsFalse(isClosed); IMultiLineString mls = g as IMultiLineString; Assert.AreEqual(mls.Count, iter.SubpathCount); foreach (ILineString lineString in (IEnumerable <ILineString>)mls) { for (Int32 vertexIndex = 0; vertexIndex < lineString.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)lineString.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } iter.NextSubpath(out start, out end, out isClosed); } } } } } } }
public void RenderingPolygonsWithGdiVectorRendererProducesCorrectGdiPaths() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable<GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); foreach (GdiRenderObject ro in renderedObjects) { IGeometry g = record.Geometry; if (g is IPolygon) { IPolygon p = g as IPolygon; using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(p.ExteriorRing.Coordinates.Count, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < p.ExteriorRing.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)p.ExteriorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } foreach (ILineString interiorRing in p.InteriorRings) { iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(interiorRing.PointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < interiorRing.PointCount; vertexIndex++) { ICoordinate v = interiorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } } } else if (g is IMultiPolygon) { IMultiPolygon mp = g as IMultiPolygon; using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { foreach (IPolygon p in (IEnumerable<IPolygon>)mp) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Int32 exteriorPointCount = p.ExteriorRing.PointCount; Assert.AreEqual(exteriorPointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < exteriorPointCount; vertexIndex++) { ICoordinate v = p.ExteriorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } foreach (ILineString interiorRing in p.InteriorRings) { iter.NextSubpath(out start, out end, out isClosed); Assert.IsTrue(isClosed); Assert.AreEqual(interiorRing.PointCount, end - start + 1); for (Int32 vertexIndex = 0; vertexIndex < interiorRing.PointCount; vertexIndex++) { ICoordinate v = interiorRing.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } } } } } } } }
public void RenderingPointsGeometriesWithGdiVectorRendererProducesCorrectGdiBitmaps() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable<GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); Int32 geoIndex = 0; foreach (GdiRenderObject ro in renderedObjects) { IGeometry g = record.Geometry; if (g is IMultiPoint) { IMultiPoint mp = g as IMultiPoint; Assert.AreEqual(mp[geoIndex][Ordinates.X], ro.Bounds.Location.X, _e); Assert.AreEqual(mp[geoIndex][Ordinates.Y], ro.Bounds.Location.Y, _e); geoIndex++; } else if (g is IPoint) { IPoint p = g as IPoint; Assert.AreEqual(p[Ordinates.X], ro.Bounds.Location.X, _e); Assert.AreEqual(p[Ordinates.Y], ro.Bounds.Location.Y, _e); } } } } }
public void RenderingLinesWithGdiVectorRendererProducesCorrectGdiPaths() { using (GdiVectorRenderer vectorRenderer = new GdiVectorRenderer()) { BasicGeometryRenderer2D<GdiRenderObject> geometryRenderer = new BasicGeometryRenderer2D<GdiRenderObject>(vectorRenderer); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); foreach (IFeatureDataRecord record in provider.ExecuteFeatureQuery(query)) { IEnumerable<GdiRenderObject> renderedObjects = geometryRenderer.RenderFeature(record); Int32 geoIndex = 0; IGeometry g = record.Geometry; foreach (GdiRenderObject ro in renderedObjects) { using (GraphicsPathIterator iter = new GraphicsPathIterator(ro.GdiPath)) { Int32 start, end; Boolean isClosed; iter.NextSubpath(out start, out end, out isClosed); if (g is ILineString) { Assert.IsFalse(isClosed); ILineString ls = g as ILineString; Assert.AreEqual(1, iter.SubpathCount); for (Int32 vertexIndex = 0; vertexIndex < ls.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)ls.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } } else if (g is IMultiLineString) { Assert.IsFalse(isClosed); IMultiLineString mls = g as IMultiLineString; Assert.AreEqual(mls.Count, iter.SubpathCount); foreach (ILineString lineString in (IEnumerable<ILineString>)mls) { for (Int32 vertexIndex = 0; vertexIndex < lineString.Coordinates.Count; vertexIndex++) { ICoordinate v = (ICoordinate)lineString.Coordinates[vertexIndex]; PointF gdiPoint = ro.GdiPath.PathPoints[vertexIndex + start]; Assert.AreEqual(v[Ordinates.X], gdiPoint.X); Assert.AreEqual(v[Ordinates.Y], gdiPoint.Y); } iter.NextSubpath(out start, out end, out isClosed); } } } } } } }