Skip to content

Instantly share code, notes, and snippets.

View oliverheilig's full-sized avatar
💾
Loading...

Oliver Heilig oliverheilig

💾
Loading...
View GitHub Profile
@oliverheilig
oliverheilig / GeoDistance.cs
Last active December 25, 2015 19:19
CalcDistance
// Calcluate airline distance based on mercator distance.
// This approximation formula is sufficiently accurate for
// our needs for distances of up to 600 km and
// 80° latitude (the error is never more than 5% even for
// extreme values).
using System;
public class Program {
public static void Main () {
double lat1 = 49.0;
@oliverheilig
oliverheilig / Transform.cs
Last active August 15, 2023 12:41
GeoTransform
// This snippet contains methods to transform between the
// various "coordinate formats" used by PTV components
using System;
public class Program
{
public static void Main()
{
var pWgs = new Point(8.4, 49.0); // Karlsruhe
var pPtv_Geodecimal =
@oliverheilig
oliverheilig / PointInRangeOfLinestring.cs
Last active December 25, 2015 19:49
PointNearLinestring
// This snippet shows how to check whether a point is near a
// polyline. For a given polyline you can check if the
// distance of a point to the line string is not greater
// a certain value.
// You can use this for geo-fencing or UI hit-testing.
using System;
using System.Collections.Generic;
using JSIL;
using JSIL.Meta;
@oliverheilig
oliverheilig / PointInsidePolygon.cs
Last active March 19, 2020 15:17
PointInsidePolygon
// This snippet shows how to check whether a point is
// contained in a polygon. Works for all polygons, even for
// OGC-invalid ones, corresponding to "fill mode" alternate.
// You can use this for geo-fencing or UI hit-testing.
using System;
using System.Collections.Generic;
using JSIL;
using JSIL.Meta;
public class Program
@oliverheilig
oliverheilig / DouglasPeuckerReduction.cs
Last active October 9, 2017 07:27
DouglasPeuckerReduction
using System;
using System.Collections.Generic;
using JSIL;
using JSIL.Meta;
public static class Program
{
public static void Main()
{
Console.WriteLine("The red line is the simplified " +
@oliverheilig
oliverheilig / CohenSutherlandClipping.cs
Last active November 20, 2016 03:28
CohenSutherlandClipping
using System;
using System.Collections.Generic;
using JSIL;
using JSIL.Meta;
public static class Program
{
public static void Main()
{
Console.WriteLine("The red line is the clipped " +
@oliverheilig
oliverheilig / CSharpGeoSnippets.md
Last active September 12, 2018 10:16
C# geo snippets

This is my list of code snippets useful when writing (geo)graphical applications in C#. Of course there are many powerful .NET libraries which handle these problems. But sometimes it is easier to just include some lines of code.

I've written the code to run directly in the browser using JSIL. You can extract the essential lines in your project. It should work for .NET, Mono, Silverlight, WinRT and Windows Phone. I've included the base types needed (Point, Rect) into the snippet. You can replace them with the appropriate type of the framework you are using.

For example: If you use the line simplification for WPF lines, you can take the System.Windows.Point. If you use it for WCF Spatial Library, you can take the [System.Spatial.GeometryPoint](http://msdn.microsoft.co

Graphing Widget

The graphing widget shows graphs using the Rickshaw graphing library. The names of data fields should be (vaguely) familiar if you've used Rickshaw before.

It's recommended that you replace the /assets/javascripts/rickshaw.min.js from your dashboard with the latest from here.

Supported HTML data fields

#map {
position: absolute;
left: 0px;
right: 0px;
top: 00px;
bottom: 0px;
}
#range {
top: 00px;
left: 0px;
#map {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}
#range {
top: 10px;
left: 0px;