using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using DelftTools.Utils; using DelftTools.Utils.Collections.Generic; using GeoAPI.CoordinateSystems; using GeoAPI.Extensions.Feature; using GeoAPI.Geometries; using SharpMap.Api.Delegates; using SharpMap.Api.Layers; namespace SharpMap.Api { public interface IMap : INameable, ICloneable { /// /// Event fired when the zoomlevel or the center point has been changed /// event MapViewChangedHandler MapViewOnChange; event MapLayerRenderedEventHandler MapLayerRendered; /// /// Event fired when all layers have been rendered /// event MapRenderedEventHandler MapRendered; event MapRenderedEventHandler MapRendering; Image Image { get; } /// /// Gets or sets a flag indicating if we should draw grid (usually latitude / longitude projected to the current map coordinate system). /// /// TODO: extract this into IMapDecoration, together with tools like NorthArrow, ScaleBar ... /// bool ShowGrid { get; set; } /// /// Gets the extents of the current map based on the current zoom, center and mapsize /// IEnvelope Envelope { get; } /// /// Using the you can alter the coordinate system of the map rendering. /// This makes it possible to rotate or rescale the image, for instance to have another direction than north upwards. /// /// /// Rotate the map output 45 degrees around its center: /// /// System.Drawing.Drawing2D.Matrix maptransform = new System.Drawing.Drawing2D.Matrix(); //Create transformation matrix /// maptransform.RotateAt(45,new PointF(myMap.Size.Width/2,myMap.Size.Height/2)); //Apply 45 degrees rotation around the center of the map /// myMap.MapTransform = maptransform; //Apply transformation to map /// /// Matrix MapTransform { get; set; } ICoordinateSystem CoordinateSystem { get; set; } /// /// A collection of layers. The first layer in the list is drawn first, the last one on top. /// IEventedList Layers { get; set; } /// /// Map background color (defaults to transparent) /// Color BackColor { get; set; } /// /// Center of map in WCS /// ICoordinate Center { get; set; } /// /// Gets or sets the zoom level of map. /// /// /// The zoom level corresponds to the width of the map in WCS units. /// A zoomlevel of 0 will result in an empty map being rendered, but will not throw an exception /// double Zoom { get; set; } double WorldHeight { get; } double WorldLeft { get; } double WorldTop { get; } /// /// Returns the size of a pixel in world coordinate units /// double PixelSize { get; } /// /// Returns the width of a pixel in world coordinate units. /// /// The value returned is the same as . double PixelWidth { get; } /// /// Returns the height of a pixel in world coordinate units. /// /// The value returned is the same as unless is different from 1. double PixelHeight { get; } /// /// Gets or sets the aspect-ratio of the pixel scales. A value less than /// 1 will make the map stretch upwards, and larger than 1 will make it smaller. /// /// Throws an argument exception when value is 0 or less. double PixelAspectRatio { get; set; } /// /// Height of map in world units /// /// double MapHeight { get; } /// /// Size of output map /// Size Size { get; set; } /// /// Minimum zoom amount allowed /// double MinimumZoom { get; set; } /// /// Maximum zoom amount allowed /// double MaximumZoom { get; set; } string Name { get; set; } bool HasDefaultEnvelopeSet { get; } bool IsDisposing { get; } /// /// Replacing layer is used, because we cannot use Layers[i] = layer. /// This is because there are a lot of places that have a NotImplementedException when /// a replace event in the collection occurs. /// HACK /// bool ReplacingLayer { get; } void ClearImage(); /// /// Renders the map to an image /// /// Image Render(); /// /// Returns an enumerable for all layers containing the search parameter in the LayerName property /// /// Search parameter /// IEnumerable IEnumerable FindLayer(string layername); /// /// Returns a layer by its name /// /// Name of layer /// Layer ILayer GetLayerByName(string layerName); /// /// Returns the (first) layer on which is present. /// /// The feature to search for. /// The layer that contains the . Null if not layer can be found. ILayer GetLayerByFeature(IFeature feature); /// /// Find the grouplayer for a given layer. Returns null if the layer is not contained in a group. /// /// Child layer to be found /// Grouplayer containing the childlayer or null if no grouplayer is found IGroupLayer GetGroupLayerContainingLayer(ILayer childLayer); void DoWithLayerRecursive(ILayer layer, Action action); IEnumerable GetAllLayers(bool includeGroupLayers); IEnumerable GetAllVisibleLayers(bool includeGroupLayers); /// /// Zooms to the extents of all layers /// Adds an extra 10 % margin to each border /// void ZoomToExtents(); /// /// Sets the layer in front of all other layers (by changing the rendering order number of the layer) /// /// void BringToFront(ILayer layer); /// /// Sets the layer behind all other layers (by changing the rendering order number of the layer) /// /// void SendToBack(ILayer layer); void SendBackward(ILayer layer); void BringForward(ILayer layer); /// /// Zooms the map to fit a bounding box /// /// /// NOTE: If the aspect ratio of the box and the aspect ratio of the mapsize /// isn't the same, the resulting map-envelope will be adjusted so that it contains /// the bounding box, thus making the resulting envelope larger! /// /// void ZoomToFit(IEnvelope bbox); /// /// Zooms the map to fit a bounding box. /// /// /// NOTE: If the aspect ratio of the box and the aspect ratio of the mapsize /// isn't the same, the resulting map-envelope will be adjusted so that it contains /// the bounding box, thus making the resulting envelope larger! /// /// /// Add a default margin? void ZoomToFit(IEnvelope bbox, bool addMargin); /// /// Converts a point from world coordinates to image coordinates based on the current /// zoom, center and mapsize. /// /// Point in world coordinates /// Point in image coordinates PointF WorldToImage(ICoordinate p); /// /// Converts a point from image coordinates to world coordinates based on the current /// zoom, center and mapsize. /// /// Point in image coordinates /// Point in world coordinates ICoordinate ImageToWorld(PointF p); /// /// Gets the extents of the map based on the extents of all the layers in the layers collection /// /// Full map extents IEnvelope GetExtents(); object Clone(); /// /// Replace a layer with another layer. /// This function is created, because we can't simply call Layer[i] = layer; /// /// /// void ReplaceLayer(ILayer sourceLayer, ILayer targetLayer); } }