Skip to content

Commit 33c6e17

Browse files
committed
Project moved to Visual Studio
1 parent 1296406 commit 33c6e17

11 files changed

+423
-11
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.rsuser
6+
*.suo
7+
*.user
8+
*.userosscache
9+
*.sln.docstates
10+
11+
# Packages
12+
packages/
13+
14+
# Build results
15+
[Dd]ebug/
16+
[Dd]ebugPublic/
17+
[Rr]elease/
18+
[Rr]eleases/
19+
x64/
20+
x86/
21+
[Aa][Rr][Mm]/
22+
[Aa][Rr][Mm]64/
23+
bld/
24+
[Bb]in/
25+
[Oo]bj/
26+
[Ll]og/
27+
[Ll]ogs/
28+
29+
# Visual Studio 2015/2017 cache/options directory
30+
.vs/
31+
32+
# Visual Studio 2017 auto generated files
33+
Generated\ Files/
34+
135
# Prerequisites
236
*.d
337

geometry-library.sln

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.106
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "geometry-library", "include\geometry-library.vcxproj", "{6FF667F1-262A-4779-81CF-FD346FE2AF62}"
7+
EndProject
8+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "tests\tests.vcxproj", "{96B63797-1621-492E-88C0-72751561874D}"
9+
EndProject
10+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "samples", "samples\samples.vcxproj", "{1587DECE-892D-47F5-863A-D7568D4D2167}"
11+
ProjectSection(ProjectDependencies) = postProject
12+
{6FF667F1-262A-4779-81CF-FD346FE2AF62} = {6FF667F1-262A-4779-81CF-FD346FE2AF62}
13+
EndProjectSection
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|x64 = Release|x64
20+
Release|x86 = Release|x86
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{6FF667F1-262A-4779-81CF-FD346FE2AF62}.Debug|x64.ActiveCfg = Debug|x64
24+
{6FF667F1-262A-4779-81CF-FD346FE2AF62}.Debug|x86.ActiveCfg = Debug|Win32
25+
{6FF667F1-262A-4779-81CF-FD346FE2AF62}.Release|x64.ActiveCfg = Debug|x64
26+
{6FF667F1-262A-4779-81CF-FD346FE2AF62}.Release|x86.ActiveCfg = Release|Win32
27+
{96B63797-1621-492E-88C0-72751561874D}.Debug|x64.ActiveCfg = Debug|x64
28+
{96B63797-1621-492E-88C0-72751561874D}.Debug|x64.Build.0 = Debug|x64
29+
{96B63797-1621-492E-88C0-72751561874D}.Debug|x86.ActiveCfg = Debug|Win32
30+
{96B63797-1621-492E-88C0-72751561874D}.Debug|x86.Build.0 = Debug|Win32
31+
{96B63797-1621-492E-88C0-72751561874D}.Release|x64.ActiveCfg = Debug|x64
32+
{96B63797-1621-492E-88C0-72751561874D}.Release|x64.Build.0 = Debug|x64
33+
{96B63797-1621-492E-88C0-72751561874D}.Release|x86.ActiveCfg = Release|Win32
34+
{96B63797-1621-492E-88C0-72751561874D}.Release|x86.Build.0 = Release|Win32
35+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Debug|x64.ActiveCfg = Debug|x64
36+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Debug|x64.Build.0 = Debug|x64
37+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Debug|x86.ActiveCfg = Debug|Win32
38+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Debug|x86.Build.0 = Debug|Win32
39+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Release|x64.ActiveCfg = Debug|x64
40+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Release|x64.Build.0 = Debug|x64
41+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Release|x86.ActiveCfg = Release|Win32
42+
{1587DECE-892D-47F5-863A-D7568D4D2167}.Release|x86.Build.0 = Release|Win32
43+
EndGlobalSection
44+
GlobalSection(SolutionProperties) = preSolution
45+
HideSolutionNode = FALSE
46+
EndGlobalSection
47+
GlobalSection(ExtensibilityGlobals) = postSolution
48+
SolutionGuid = {16C2AA62-9846-4234-962E-007CD4A92124}
49+
EndGlobalSection
50+
EndGlobal

src/LatLng.hpp renamed to include/LatLng.hpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,32 @@
1414
#ifndef GEOMETRY_LIBRARY_LATLNG
1515
#define GEOMETRY_LIBRARY_LATLNG
1616

17-
struct LatLng {
18-
double lat;
19-
double lng;
17+
#include <cmath>
2018

21-
LatLng(double lat, double lng)
22-
: lat(lat), lng(lng) {};
19+
class LatLng {
20+
public:
21+
double lat; // The latitude of this location
22+
double lng; // The longitude of this location
23+
24+
/**
25+
* Constructs a location with a latitude/longitude pair.
26+
*
27+
* @param lat The latitude of this location.
28+
* @param lng The longitude of this location.
29+
*/
30+
LatLng(double lat, double lng)
31+
: lat(lat), lng(lng) {}
2332

2433
bool operator==(const LatLng& other) {
25-
return lat == other.lat && lng == other.lng;
34+
return isCoordinateEqual(lat, other.lat) &&
35+
isCoordinateEqual(lng, other.lng);
2636
}
37+
38+
39+
private:
40+
bool isCoordinateEqual(double first, double second) {
41+
return std::fabs(first - second) < 1e-12;
42+
}
2743
};
2844

2945
#endif // GEOMETRY_LIBRARY_LATLNG
File renamed without changes.
File renamed without changes.

src/SphericalUtil.hpp renamed to include/SphericalUtil.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class SphericalUtil {
8686
double n1 = cos(distance);
8787
double n2 = sin(distance) * cos(heading);
8888
double n3 = sin(distance) * sin(heading);
89-
double n4 = sin(rad2deg(to.lat));
89+
double n4 = sin(deg2rad(to.lat));
9090
// There are two solutions for b. b = n2 * n4 +/- sqrt(), one solution results
9191
// in the latitude outside the [-90, 90] range. We first try one solution and
9292
// back off to the other if we are outside that range.
@@ -181,8 +181,8 @@ class SphericalUtil {
181181
double lat = deg2rad(point.lat);
182182
double lng = deg2rad(point.lng);
183183
length += SphericalUtil::distanceRadians(prevLat, prevLng, lat, lng);
184-
double prevLat = lat;
185-
double prevLng = lng;
184+
prevLat = lat;
185+
prevLng = lng;
186186
}
187187
return length * MathUtil::EARTH_RADIUS;
188188
}
@@ -239,8 +239,8 @@ class SphericalUtil {
239239
double tanLat = tan((M_PI / 2 - deg2rad(point.lat)) / 2);
240240
double lng = deg2rad(point.lng);
241241
total += SphericalUtil::polarTriangleArea(tanLat, lng, prevTanLat, prevLng);
242-
double prevTanLat = tanLat;
243-
double prevLng = lng;
242+
prevTanLat = tanLat;
243+
prevLng = lng;
244244
}
245245
return total * (radius * radius);
246246
}

include/geometry-library.vcxproj

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<ProjectGuid>{6FF667F1-262A-4779-81CF-FD346FE2AF62}</ProjectGuid>
24+
<RootNamespace>geometrylibrary</RootNamespace>
25+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v142</PlatformToolset>
32+
<CharacterSet>MultiByte</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v142</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>MultiByte</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v141</PlatformToolset>
45+
<CharacterSet>MultiByte</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>Application</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v141</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>MultiByte</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<Optimization>Disabled</Optimization>
77+
<SDLCheck>true</SDLCheck>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
<Link>
81+
<SubSystem>Console</SubSystem>
82+
</Link>
83+
</ItemDefinitionGroup>
84+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
85+
<ClCompile>
86+
<WarningLevel>Level3</WarningLevel>
87+
<Optimization>Disabled</Optimization>
88+
<SDLCheck>true</SDLCheck>
89+
<ConformanceMode>true</ConformanceMode>
90+
</ClCompile>
91+
<Link>
92+
<SubSystem>Console</SubSystem>
93+
</Link>
94+
</ItemDefinitionGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
96+
<ClCompile>
97+
<WarningLevel>Level3</WarningLevel>
98+
<Optimization>MaxSpeed</Optimization>
99+
<FunctionLevelLinking>true</FunctionLevelLinking>
100+
<IntrinsicFunctions>true</IntrinsicFunctions>
101+
<SDLCheck>true</SDLCheck>
102+
<ConformanceMode>true</ConformanceMode>
103+
</ClCompile>
104+
<Link>
105+
<SubSystem>Console</SubSystem>
106+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
107+
<OptimizeReferences>true</OptimizeReferences>
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
111+
<ClCompile>
112+
<WarningLevel>Level3</WarningLevel>
113+
<Optimization>MaxSpeed</Optimization>
114+
<FunctionLevelLinking>true</FunctionLevelLinking>
115+
<IntrinsicFunctions>true</IntrinsicFunctions>
116+
<SDLCheck>true</SDLCheck>
117+
<ConformanceMode>true</ConformanceMode>
118+
</ClCompile>
119+
<Link>
120+
<SubSystem>Console</SubSystem>
121+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
122+
<OptimizeReferences>true</OptimizeReferences>
123+
</Link>
124+
</ItemDefinitionGroup>
125+
<ItemGroup>
126+
<ClInclude Include="LatLng.hpp" />
127+
<ClInclude Include="MathUtil.hpp" />
128+
<ClInclude Include="SphericalUtil.hpp" />
129+
</ItemGroup>
130+
<ItemGroup>
131+
<ClCompile Include="PolyUtil.hpp" />
132+
</ItemGroup>
133+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
134+
<ImportGroup Label="ExtensionTargets">
135+
</ImportGroup>
136+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<ClInclude Include="LatLng.hpp" />
5+
<ClInclude Include="MathUtil.hpp" />
6+
<ClInclude Include="SphericalUtil.hpp" />
7+
</ItemGroup>
8+
<ItemGroup>
9+
<ClCompile Include="PolyUtil.hpp" />
10+
</ItemGroup>
11+
</Project>

samples/samples.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
#include "SphericalUtil.hpp"
5+
6+
7+
int main() {
8+
LatLng up = { 90.0, 0.0 };
9+
LatLng down = {-90.0, 0.0 };
10+
LatLng front = { 0.0, 0.0 };
11+
LatLng right = { 0.0, 90.0 };
12+
13+
auto angle = SphericalUtil::computeAngleBetween(up, right);
14+
std::cout << "The angle between up and right is " << rad2deg(angle) << " degrees" << std::endl;
15+
16+
auto distance = SphericalUtil::computeDistanceBetween(up, down);
17+
std::cout << "The distance between up and down is " << distance << " meters" << std::endl;
18+
19+
std::vector<LatLng> points = { front, up, right };
20+
21+
auto length = SphericalUtil::computeLength(points);
22+
std::cout << "The length between front, up and right is " << length << " meters" << std::endl;
23+
24+
auto area = SphericalUtil::computeArea(points);
25+
std::cout << "The area between front, up and right is " << area << " square meters" << std::endl;
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)