175 lines
6.2 KiB
C#
175 lines
6.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="MapModel.cs" company="BTU/IIT">
|
|
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
|
// </copyright>
|
|
// <author>Stubbfel</author>
|
|
// <date>14.10.2013</date>
|
|
// <summary>Implements the map model class</summary>
|
|
//-----------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Model.Campusmap.Map
|
|
{
|
|
using CampusAppWPortalLib8.Model.GeoDb;
|
|
using CampusAppWPortalLib8.Model.Utility;
|
|
using System.Collections.Generic;
|
|
|
|
/// <summary> This Class manage the properties of a Map. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
public class MapModel<T, V>
|
|
where V : PlaceModel
|
|
where T : SpsModel<V>, new()
|
|
{
|
|
#region Constructors
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="MapModel" /> class. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
public MapModel()
|
|
{
|
|
this.IsReady = false;
|
|
}
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="MapModel" /> class. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="placeList"> list of places. </param>
|
|
public MapModel(List<V> placeList)
|
|
{
|
|
this.IsReady = false;
|
|
this.LoadSpatials(placeList);
|
|
this.IsReady = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Property
|
|
|
|
/// <summary> Gets or sets a value indicating whether the map is ready or not. </summary>
|
|
/// <value> true if this object is ready, false if not. </value>
|
|
public bool IsReady { get; protected set; }
|
|
|
|
/// <summary> Gets or sets the ImageSource of the map. </summary>
|
|
/// <value> The image source. </value>
|
|
public string ImageSource { get; set; }
|
|
|
|
/// <summary> Gets or sets the ImageWidth of the map. </summary>
|
|
/// <value> The width of the image. </value>
|
|
public double ImageWidth { get; set; }
|
|
|
|
/// <summary> Gets or sets the ImageHeight of the map. </summary>
|
|
/// <value> The height of the image. </value>
|
|
public double ImageHeight { get; set; }
|
|
|
|
/// <summary> Gets or sets the ImageOffsetX of the map. </summary>
|
|
/// <value> The map image offset x coordinate. </value>
|
|
public MapPoint MapImageOffsetPoint { get; set; }
|
|
|
|
/// <summary> Gets or sets the GeoOffsetX of the map. </summary>
|
|
/// <value> The geo offset x coordinate. </value>
|
|
public MapPoint GeoOffsetPoint { get; set; }
|
|
|
|
/// <summary> Gets or sets the Scale (to pixel) of the map. </summary>
|
|
/// <value> The scale x coordinate. </value>
|
|
public MapPoint ScalePoint { get; set; }
|
|
|
|
/// <summary> Gets or sets the spatial of the map. </summary>
|
|
/// <value> The spatial. </value>
|
|
public T Spatial { get; set; }
|
|
|
|
/// <summary> Gets or sets the reference point. </summary>
|
|
/// <value> The reference point. </value>
|
|
public MapPoint RefPoint { get; set; }
|
|
|
|
public MapPoint MapRefPoint
|
|
{
|
|
get
|
|
{
|
|
return this.MapImageOffsetPoint + this.RefPoint;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
#region public
|
|
|
|
/// <summary> Gets scroll point. </summary>
|
|
/// <remarks> Stubbfel, 21.10.2013. </remarks>
|
|
/// <param name="point"> The point. </param>
|
|
/// <returns> The scroll point. </returns>
|
|
public MapPoint GetScrollPoint(MapPoint point)
|
|
{
|
|
MapPoint result = this.MapRefPoint;
|
|
result.X += point.X;
|
|
result.Y -= point.Y;
|
|
return result;
|
|
}
|
|
|
|
/// <summary> Gets scroll point. </summary>
|
|
/// <remarks> Stubbfel, 21.10.2013. </remarks>
|
|
/// <param name="x"> The x coordinate. </param>
|
|
/// <param name="y"> The y coordinate. </param>
|
|
/// <returns> The scroll point. </returns>
|
|
public MapPoint GetScrollPoint(double x, double y)
|
|
{
|
|
return this.GetScrollPoint(new MapPoint(x, y));
|
|
}
|
|
|
|
|
|
/// <summary> Convert a coordinates to coordinates which address pixels. </summary>
|
|
/// <remarks> Stubbfel, 27.08.2013. </remarks>
|
|
/// <param name="x"> the x-coordinate. </param>
|
|
/// <param name="y"> the y-coordinate. </param>
|
|
/// <returns> Point in pixel-size. </returns>
|
|
public MapPoint ConverToPixelPoint(double x, double y)
|
|
{
|
|
return this.ConverToPixelPoint(new MapPoint(x,y));
|
|
}
|
|
|
|
/// <summary> Convert a coordinates to coordinates which address pixels. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="point"> not scaled point. </param>
|
|
/// <returns> Point in pixel-size. </returns>
|
|
public MapPoint ConverToPixelPoint(MapPoint point)
|
|
{
|
|
return point * this.ScalePoint;
|
|
}
|
|
|
|
/// <summary> Convert a coordinates to coordinates which address mapPoint. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="x"> the x-coordinate. </param>
|
|
/// <param name="y"> the y-coordinate. </param>
|
|
/// <returns> Point in pixel-size. </returns>
|
|
public MapPoint ConverToMapPoint(double x, double y)
|
|
{
|
|
return this.ConverToMapPoint(new MapPoint(x, y));
|
|
}
|
|
|
|
/// <summary> Convert a coordinates to coordinates which address mapPoint. </summary>
|
|
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
|
/// <param name="point"> not scaled point. </param>
|
|
/// <returns> Point in pixel-size. </returns>
|
|
public MapPoint ConverToMapPoint(MapPoint point)
|
|
{
|
|
MapPoint result = point - this.GeoOffsetPoint;
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region protected
|
|
|
|
/// <summary> Loads the spatial object </summary>
|
|
/// <remarks> Stubbfel, 19.08.2013. </remarks>
|
|
/// <param name="placeList"> list of places. </param>
|
|
protected virtual void LoadSpatials(List<V> placeList)
|
|
{
|
|
this.Spatial = new T();
|
|
this.Spatial.AddPlaces(placeList);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|