Skip to content

Commit

Permalink
Added Google static maps parser for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gh0stWalk3r committed Jan 3, 2016
1 parent 312c5e3 commit ef62b39
Show file tree
Hide file tree
Showing 20 changed files with 1,116 additions and 16 deletions.
1 change: 1 addition & 0 deletions Product/Gui/Config-Gui/BrowserConfigViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace At.FF.Krems.Config_Gui
using System.Linq;
using System.Runtime.CompilerServices;

using At.FF.Krems.Configuration.Google.StaticMaps.Enums;
using At.FF.Krems.Config_Gui.Annotations;
using At.FF.Krems.Configuration.XML;

Expand Down
1 change: 1 addition & 0 deletions Product/Gui/FullscreenBrowser/Print/PrintController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private void InternalPrint(bool automaticPrint)

if (string.IsNullOrWhiteSpace(item.MapUrl))
{
// Google Static Maps Developer Guide: https://developers.google.com/maps/documentation/static-maps/intro
var mapData =
this.GetData(
$"https://secure.florian10.info/ows/infoscreen/geo/staticmap.ashx?address={item.Strasse}{(string.IsNullOrWhiteSpace(item.Nummer1) ? string.Empty : "%20" + item.Nummer1)},%20{item.Plz}%20{item.Ort}");
Expand Down
17 changes: 17 additions & 0 deletions Product/Shared/Configuration/Configuration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
<Compile Include="..\..\..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Google\ILocationString.cs" />
<Compile Include="Google\QueryStringParametersList.cs" />
<Compile Include="Google\StaticMaps\Entities\ImageSize.cs" />
<Compile Include="Google\StaticMaps\Entities\MapStyle.cs" />
<Compile Include="Google\StaticMaps\Entities\Marker.cs" />
<Compile Include="Google\StaticMaps\Entities\MarkerStyle.cs" />
<Compile Include="Google\StaticMaps\Entities\Path.cs" />
<Compile Include="Google\StaticMaps\Entities\PathStyle.cs" />
<Compile Include="Google\StaticMaps\Entities\StaticMapRequest.cs" />
<Compile Include="Google\StaticMaps\Enums\ImageFormat.cs" />
<Compile Include="Google\StaticMaps\Enums\MapElement.cs" />
<Compile Include="Google\StaticMaps\Enums\MapFeature.cs" />
<Compile Include="Google\StaticMaps\Enums\MapType.cs" />
<Compile Include="Google\StaticMaps\Enums\MapVisibility.cs" />
<Compile Include="Google\StaticMaps\Enums\MarkerSize.cs" />
<Compile Include="Google\StaticMaps\StaticMapsEngine.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XML\BrowserConfig.cs" />
<Compile Include="XML\Cookie.cs" />
Expand All @@ -57,6 +73,7 @@
<Compile Include="XML\WindowPosition.cs" />
<Compile Include="XML\WindowProxy.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
31 changes: 31 additions & 0 deletions Product/Shared/Configuration/Google/ILocationString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ILocationString.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google
{
public interface ILocationString
{
string LocationString { get; }
}
}
45 changes: 45 additions & 0 deletions Product/Shared/Configuration/Google/QueryStringParametersList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="QueryStringParametersList.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google
{
using System;
using System.Collections.Generic;
using System.Linq;

public class QueryStringParametersList
{
private List<KeyValuePair<string, string>> List { get; } = new List<KeyValuePair<string, string>>();

public void Add(string key, string value)
{
this.List.Add(new KeyValuePair<string, string>(key, value));
}

public string GetQueryStringPostfix()
{
return string.Join("&", this.List.Select(p => Uri.EscapeDataString(p.Key) + "=" + Uri.EscapeDataString(p.Value)));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ImageSize.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google.StaticMaps.Entities
{
/// <summary>
/// Images may be retrieved in sizes up to 640 by 640 pixels.
/// The size parameter takes a string with two values separated by the x character.
/// 640x640 is the largest image size allowed.
/// Note that the center parameter, combined with the size parameter implicitly defines the coverage area of the map image.
/// </summary>
public struct ImageSize
{
public readonly int Width;
public readonly int Height;

public ImageSize(int width, int height)
{
this.Width = width;
this.Height = height;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MapStyle.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google.StaticMaps.Entities
{
using At.FF.Krems.Configuration.Google.StaticMaps.Enums;

/// <summary>
/// Styled maps allow you to customize the presentation of the standard Google map styles, changing the visual display of such elements as roads, parks, and built-up areas to reflect a different style than that used in the default map type.
/// These components are known as features and a styled map allows you to select these features and apply visual styles to their display (including hiding them entirely).
/// With these changes, the map can be made to emphasize particular components or complement content within the surrounding page.
/// A customized "styled" map consists of one or more specified styles, each indicated through a style parameter within the Static Map request URL.
/// Additional styles are specified by passing additional style parameters.
/// A style consists of a selection(s) and a set of rules to apply to that selection.
/// The rules indicate what visual modification to make to the selection.
/// </summary>
public class MapStyle
{
/// <summary>
/// (optional) indicates what features to select for this style modification. (See Map Features below.) If no feature argument is passed, all features will be selected.
/// </summary>
public MapFeature MapFeature { get; set; }

/// <summary>
/// (optional) indicates what sub-set of the selected features to select. (See Map Elements below.) If no element argument is passed, all elements of the given feature will be selected.
/// </summary>
public MapElement MapElement { get; set; }

/// <summary>
/// (an RGB hex string of format 0xRRGGBB) indicates the basic color to apply to the selection.
/// </summary>
// ReSharper disable once InconsistentNaming
public string HUE { get; set; }

/// <summary>
/// (a floating point value between -100 and 100) indicates the percentage change in brightness of the element. Negative values increase darkness (where -100 specifies black) while positive values increase brightness (where +100 specifies white).
/// </summary>
public float? Lightness { get; set; }

/// <summary>
/// (a floating point value between -100 and 100) indicates the percentage change in intensity of the basic color to apply to the element.
/// </summary>
public float? Saturation { get; set; }

/// <summary>
/// (a floating point value between 0.01 and 10.0, where 1.0 applies no correction) indicates the amount of gamma correction to apply to the element. Gammas modify the lightness of hues in a non-linear fashion, while unaffecting white or black values. Gammas are typically used to modify the contrast of multiple elements. For example, you could modify the gamma to increase or decrease the contrast between the edges and interiors of elements. Low gamma values (less than 1) increase contrast, while high values (> 1) decrease contrast.
/// </summary>
public float? Gamma { get; set; }

/// <summary>
/// simply inverts the existing lightness.
/// </summary>
public bool InverseLightness { get; set; }

/// <summary>
/// indicates whether and how the element appears on the map. visibility:simplified indicates that the map should simplify the presentation of those elements as it sees fit. (A simplified road structure may show fewer roads, for example.)
/// </summary>
public MapVisibility MapVisibility { get; set; }
}
}
41 changes: 41 additions & 0 deletions Product/Shared/Configuration/Google/StaticMaps/Entities/Marker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Marker.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google.StaticMaps.Entities
{
using System.Collections.Generic;

/// <summary>
/// The markers parameter defines a set of one or more markers at a set of locations. Each marker defined within a single markers declaration must exhibit the same visual style; if you wish to display markers with different styles, you will need to supply multiple markers parameters with separate style information.
/// </summary>
public class Marker
{
/// <summary>
/// Marker's style
/// </summary>
public MarkerStyle Style { get; set; }

public IList<ILocationString> Locations { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MarkerStyle.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google.StaticMaps.Entities
{
using At.FF.Krems.Configuration.Google.StaticMaps.Enums;

public class MarkerStyle
{
/// <summary>
/// (optional) specifies the size of marker from the set {tiny, mid, small}. If no size parameter is set, the marker will appear in its default (normal) size.
/// </summary>
public MarkerSize Size { get; set; }

/// <summary>
/// optional) specifies a 24-bit color (example: color=0xFFFFCC) or a predefined color from the set {black, brown, green, purple, yellow, blue, gray, orange, red, white}.
/// Note that transparencies (specified using 32-bit hex color values) are not supported in markers, though they are supported for paths.
/// </summary>
public string Color { get; set; }

/// <summary>
/// (optional) specifies a single uppercase alphanumeric character from the set {A-Z, 0-9}.
/// (The requirement for uppercase characters is new to this version of the API.)
/// Note that default and mid sized markers are the only markers capable of displaying an alphanumeric-character parameter.
/// tiny and small markers are not capable of displaying an alphanumeric-character.
/// </summary>
public string Label { get; set; }
}
}
35 changes: 35 additions & 0 deletions Product/Shared/Configuration/Google/StaticMaps/Entities/Path.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Path.cs" company="Freiwillige Feuerwehr Krems/Donau">
// Freiwillige Feuerwehr Krems/Donau
// Austraße 33
// A-3500 Krems/Donau
// Austria
// Tel.: +43 (0)2732 85522
// Fax.: +43 (0)2732 85522 40
// E-mail: [email protected]
//
// This software is furnished under a license and may be
// used and copied only in accordance with the terms of
// such license and with the inclusion of the above
// copyright notice. This software or any other copies
// thereof may not be provided or otherwise made
// available to any other person. No title to and
// ownership of the software is hereby transferred.
//
// The information in this software is subject to change
// without notice and should not be construed as a
// commitment by Freiwillige Feuerwehr Krems/Donau.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace At.FF.Krems.Configuration.Google.StaticMaps.Entities
{
using System.Collections.Generic;

public class Path
{
public PathStyle Style { get; set; }

public IList<ILocationString> Locations { get; set; }
}
}
Loading

0 comments on commit ef62b39

Please sign in to comment.