473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for C# libraries of "Haversign" spatial functions


I have a database of lat/long positions. What I want to be able to do is to
be able to filter that database based on a selection by the user. In other
words the user picks point X and I want to know all the locations in my DB
that are within say, 50 feet or 500 feet of that point.

I am told there are several ways to do this. One way is to use a database
with spatial query support and write spatial queries. I'm told the other,
Old Skool way to do this is to use something called "haversign functions" --
sorry if I'm mangling the spelling -- and loop through your dataset (or
filter it in some more efficient way).

I will be using a spatially aware DB in the future. I would like to know how
to do this "manually", in programming, using the Haversign functions. I am
competent with working with C# and VS.NET. Can someone point me to a port of
these functions for C#?

Thanks,
-KF
Jun 27 '08 #1
2 2469
Ah, good. I was baffled why my Googling offered only a few esoteric results.
For the benefit of anyone else going down the same path, this will get you
started:

http://www.codeproject.com/KB/cs/dis...select=1309714

This includes a SQL function you could use in a non-spatially aware DB:
http://megocode3.wordpress.com/2008/...-formula-in-c/

JavaScript implementation:
http://groups.google.com.jm/group/Go...f089ac7277e828

PHP
http://www.go4expert.com/forums/showthread.php?t=339

Wikipedia:
http://en.wikipedia.org/wiki/Haversine_formula

-KF
"MC" <fo************ **@www.ai.uga.e du.slash.mcwrot e in message
news:#V******** ******@TK2MSFTN GP06.phx.gbl...
It's "haversine" and is well covered in Wikipedia.
"Ken Fine" <ke*****@newsgr oup.nospamwrote in message
news:8E******** *************** ***********@mic rosoft.com...
>>
I have a database of lat/long positions. What I want to be able to do is
to
be able to filter that database based on a selection by the user. In
other
words the user picks point X and I want to know all the locations in my
DB
that are within say, 50 feet or 500 feet of that point.

I am told there are several ways to do this. One way is to use a database
with spatial query support and write spatial queries. I'm told the other,
Old Skool way to do this is to use something called "haversign
functions" --
sorry if I'm mangling the spelling -- and loop through your dataset (or
filter it in some more efficient way).

I will be using a spatially aware DB in the future. I would like to know
how
to do this "manually", in programming, using the Haversign functions. I
am
competent with working with C# and VS.NET. Can someone point me to a port
of
these functions for C#?

Thanks,
-KF

Jun 27 '08 #2
Hi KF,

Thanks for sharing the resources with us. Really interesting and
informative.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
--------------------
>From: "Ken Fine" <ke*****@newsgr oup.nospam>
References: <8E************ *************** *******@microso ft.com>
<#V************ **@TK2MSFTNGP06 .phx.gbl>
>Subject: Re: Looking for C# libraries of "Haversign" spatial functions
Date: Mon, 16 Jun 2008 16:45:17 -0700
>
Ah, good. I was baffled why my Googling offered only a few esoteric
results.
>For the benefit of anyone else going down the same path, this will get you
started:

http://www.codeproject.com/KB/cs/dis...x?df=100&forum
id=245892&exp=0 &select=1309 714
>
This includes a SQL function you could use in a non-spatially aware DB:
http://megocode3.wordpress.com/2008/...-formula-in-c/

JavaScript implementation:
http://groups.google.com.jm/group/Go...ad/thread/2ef0
89ac7277e828
>
PHP
http://www.go4expert.com/forums/showthread.php?t=339

Wikipedia:
http://en.wikipedia.org/wiki/Haversine_formula

-KF
"MC" <fo************ **@www.ai.uga.e du.slash.mcwrot e in message
news:#V******* *******@TK2MSFT NGP06.phx.gbl.. .
>It's "haversine" and is well covered in Wikipedia.
"Ken Fine" <ke*****@newsgr oup.nospamwrote in message
news:8E******* *************** ************@mi crosoft.com...
>>>
I have a database of lat/long positions. What I want to be able to do
is
>>to
be able to filter that database based on a selection by the user. In
other
words the user picks point X and I want to know all the locations in my
DB
that are within say, 50 feet or 500 feet of that point.

I am told there are several ways to do this. One way is to use a
database
>>with spatial query support and write spatial queries. I'm told the
other,
>>Old Skool way to do this is to use something called "haversign
functions" --
sorry if I'm mangling the spelling -- and loop through your dataset (or
filter it in some more efficient way).

I will be using a spatially aware DB in the future. I would like to
know
>>how
to do this "manually", in programming, using the Haversign functions. I
am
competent with working with C# and VS.NET. Can someone point me to a
port
>>of
these functions for C#?

Thanks,
-KF

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1417
by: Michele Locati | last post by:
Hello NG! I'm going to use MySQL to manage spatial data in a website made with PHP. In its manual I've seen that MySQL can manage georeferenced elements (points, lines and so on). But this spatial extension stil lacks some functionality, and by a web search it seems to me that these functions are missing from year(s). What I need most is the DISTANCE() function beetween two geometric
0
5164
by: Kiyoung Yang | last post by:
Hi, I'm using Oracle 9i with the spatial option. It seems that the spatial function, e.g., SDO_NN, does not consider the 3rd element in a point. I tried the following script to create a table, insert 2 points, create an index, and to query the table using SDO_NN. -------------------< script for Oracle >---------------------- create table test (shape MDSYS.SDO_GEOMETRY);
3
5168
by: David Hayes | last post by:
I've made tooltips work in Firefox*, but tooltip doesn't appear at the specified location until the SECOND time that the user passes the mouse over the location with the mouseover event. What I want is for the user to be able to put the mouse over text that gives a year (e.g., "(1932)", "(1946)" and "(1923)") and see the tooltip to the right and slightly beneath the year. (For the record -- this needn't concern the debugging effort --...
1
1632
by: paul | last post by:
library for querying virtual polygon over raster spatial data in my c++ application, after calculating my polygon i wish to define it (simple 4 sided polygon with floats or line parameters) and use this to query a b/w image in memory, i want to get the pixel counts, full, hopefully partial, perhaps specific to a side, data to calculate area ect, can someone help point me to a library paul
2
3134
by: Belinda | last post by:
Hi. I am just getting started with DB2's spatial extender and could really use some help. Pointers to good docs or examples are welcome. I am using DB2 version 8 on Sun. I have a database of genomic data and believe the spatial extender will help in querying. I have to do intersections, subtractions, proximity, etc of ranges in the chromosomes. The database and even some tables include data on all chromosomes of several species. I am...
9
2623
by: Gibby Koldenhof | last post by:
Hiya, Terrible subject but I haven't got a better term at the moment. I've been building up my own library of functionality (all nice conforming ISO C) for over 6 years and decided to adopt a more OO approach to fit my needs. Altough I used an OO approach previously for some subparts of the library it became somewhat difficult to maintain all those parts since they really are the same thing coded for each part (code duplication). So...
11
3308
by: Brad | last post by:
To DB2 Personal Developer Edition GIS users: How do I acquire a spatial extender license key for the DB2 PDE? I expected to be able to use it right out of the box. Brad
10
1902
by: ampeloso | last post by:
I'm pretty new to c coming from other MS languages. I have a few questions about library functions 1. The headers specify the functions, but where are the actual functions.Apparently they are precompiled, but can you see the original code? 2. Are the functions in the dll's? 3. If so where in your code are you telling the program to use the dll?
0
884
Lokean
by: Lokean | last post by:
Hi, I'm a VB.net programmer who is coordingating with our SQL Server specialist to convert functions into vb CLR projects. We want to use statistical functions, but we can not port them directly. Does anyone know of existing code libraries of aggregate statistical functions? I can go and code each one, but I'd rather not....
0
8302
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.