//
// \92n\8b\85\8aO\8eü\82ð\90Ô\93¹\94¼\8ca\82©\82ç\8eZ\8fo\82·\82é\81B
// \90Ô\93¹\94¼\8ca\82Í6378.137\82È\82Ì\82Å\8aO\8eü\82Í2*M_PI_*6378.137
+ //
+ // 9\8eü\94N\8bL\94O\83C\83x\83\93\83g\82Ì\81u0.1km\81v\94\8c¾\8by\82Ñ\83~\83b\83V\83\87\83\93\82P\82Å\82Ì\8dq\8ds\8b\97\97£\8fW\8cv\92l\82©\82ç1\90¢\8aE\8dÀ\95W=0.1km\82Æ\94»\96¾\81B
+ // \82Æ\82Í\82¢\82¦\95¢\82³\82ê\82é\89Â\94\\90«\82à\8d\82\82¢\82Ì\82Å\95Û\97¯\82Æ\82µ\82Ä\82¨\82\81B
inline double s_velocityByKnot( const double velocity )
{
static const double k_knotFactor = (2 * M_PI * 6378.137) / 16384.0 / 0.4 / 1.852;
#include "stdafx.h"
#include "GVOShipRoute.h"
+#include "GVOVector.h"
namespace {
const float k_worldLoopThreshold = 0.5f;
-}
-
-
-GVOShipRoute::GVOShipRoute()
-{
-}
-
-GVOShipRoute::~GVOShipRoute()
-{
+ inline POINT s_denormalizedPoint( const GVONormalizedPoint & point )
+ {
+ POINT p = {
+ static_cast<long>(::round( point.x() * k_worldWidth )),
+ static_cast<long>(::round( point.y() * k_worldHeight )),
+ };
+ return p;
+ }
}
if ( m_lines.empty() ) {
m_lines.push_back( Line() );
}
+
Line & line = m_lines.back();
if ( line.empty() ) {
line.push_back( point );
return;
}
+
+ GVOVector vector( s_denormalizedPoint( line.back() ), s_denormalizedPoint( point ) );
+ m_length += static_cast<int64_t>(::round( vector.length() ));
+
const GVONormalizedPoint & prevPoint = line.back();
if ( prevPoint.isEqualValue( point ) ) {
return;
}
// \90¢\8aE\82ð\8c×\82¢\82¾\8fê\8d\87\82Í\90ü\82ð\95ª\8a\84\82·\82é
-
if ( prevPoint.x() < point.x() && (k_worldLoopThreshold <= (point.x() - prevPoint.x())) ) {
// \90¼\82É\8cü\82©\82Á\82Ä\8c×\82¢\82¾\8fê\8d\87
const GVONormalizedPoint leftSideSubPoint( point.x() - 1.0f, point.y() );
return;
}
+
+ // \82Q\82Â\82Ì\8dq\98H\82Ì\92·\82³\82ð\91«\82·
+ m_length += srcRoute.m_length;
+
+
Lines tmp = srcRoute.m_lines;
// \91O\82Ì\8dq\98H\82Ì\8fI\93_\82Æ\8c»\8dÝ\82Ì\8dq\98H\82Ì\8en\93_\82ª\98A\8c\8b\89Â\94\\82È\82ç\83\89\83C\83\93\82ð\8cq\82°\82È\82¯\82ê\82Î\82È\82ç\82È\82¢
GVONormalizedPoint prevPoint = prevLine.back();
GVONormalizedPoint nextPoint = nextLine.front();
+ // \8dq\98H\8aÔ\82Ì\92·\82³\82ð\91«\82·
+ const double betweenLength = GVOVector( s_denormalizedPoint( prevPoint ), s_denormalizedPoint( nextPoint ) ).length();
+ m_length += static_cast<int64_t>(::round( betweenLength ));
+
// \90¢\8aE\82ð\8c×\82¢\82Å\82¢\82È\82¢\82æ\82¤\82È\82ç\90ü\82ð\90Ú\91±\82·\82é
if ( (std::max( prevPoint.x(), nextPoint.x() ) - std::min(prevPoint.x(), nextPoint.x())) < k_worldLoopThreshold ) {
prevLine.insert( prevLine.end(), nextLine.begin(), nextLine.end() );
typedef std::deque<Line> Lines;
private:
Lines m_lines;
+ int64_t m_length = 0;
bool m_favorite = false;
bool m_hilight = false;
bool m_fixed = false; //!<@brief \8dq\98H\8cÅ\92è\83t\83\89\83O
public:
- GVOShipRoute();
- ~GVOShipRoute();
+ GVOShipRoute() = default;
+ ~GVOShipRoute() = default;
//!@attention \8cÅ\92è\82³\82ê\82½\8dq\98H\82É\8dÀ\95W\82ð\92Ç\89Á\82µ\82Ä\82Í\82È\82ç\82È\82¢\81B\83\8d\83W\83b\83N\83G\83\89\81[\82È\82Ì\82ÅDebug\8e\9e\82Ì\82Ý\83G\83\89\81[\82Æ\82µ\82Ä\82¢\82é\81B
void addRoutePoint( const GVONormalizedPoint & point );
{
m_fixed = isFixed;
}
+
+ int64_t length() const
+ {
+ return m_length;
+ }
private:
};
}
}
break;
+ case k_ColumnIndex_Length:
+ if ( route->getLines().empty() ) {
+ str = L"-";
+ }
+ else {
+ //float length = route->length() / 10.0f;
+ //std::vector<wchar_t> buf( 4096 );
+ //::swprintf( &buf[0], buf.size(), L"%.1f km", length );
+ //str = &buf[0];
+ str = std::to_wstring( route->length() );
+ }
+ break;
default:
break;
}
ListView_InsertColumn( m_listViewCtrl, index, &column );
++index;
+ column.pszText = L"\8dq\8ds\8b\97\97£";
+ ListView_InsertColumn( m_listViewCtrl, index, &column );
+ ++index;
+
updateVisibleListItemCount();
for ( int i = 0; i < index; i++ ) {
enum ColumnIndex {
k_ColumnIndex_StartPoint,
k_ColumnIndex_EndPoint,
+ k_ColumnIndex_Length,
};
enum IconIndex {
k_IconIndex_Blank,
#pragma once
#include <math.h>
#include "GVONavish.h"
-
-
+#include "GVONormalizedPoint.h"
// \8aÈ\88Õ\93ñ\8e\9f\8c³\83x\83N\83g\83\8b
class GVOVector {
private:
- double m_x;
- double m_y;
- double m_length;
+ double m_x = 0.0;
+ double m_y = 0.0;
+ double m_length = 0.0;
public:
- GVOVector() :
- m_x(),
- m_y(),
- m_length()
- {
- }
+ GVOVector() = default;
GVOVector( const double x, const double y ) :
m_x( x ),
m_y( y ),
// \90¢\8aE\8dÀ\95W\82Ì2\93_\82©\82ç\83x\83N\83g\83\8b\82ð\8eZ\8fo\82·\82é\81B
// \82½\82¾\82µX\8e²\82ª\90¢\8aE\82Ì\94¼\95ª\88È\8fã\97£\82ê\82Ä\82¢\82é\82Æ\8bt\95û\8cü\82Å\83x\83N\83g\83\8b\82ð\8eæ\82é\81B
// \81i\89~\93\9b\8fã\82Ì\8bß\82¢\95û\82Ì\8b\97\97£\82ð\8dÌ\97p\82·\82é\81j
- GVOVector( const POINT& p1, const POINT& p2 ) :
- m_x(),
- m_y(),
- m_length()
+ //
+ // TODO: \82Å\82«\82ê\82ÎWorldMap\82É\8f\88\97\9d\82ð\88Ú\82µ\82½\82¢\81B
+ GVOVector( const POINT& p1, const POINT& p2 )
{
const LONG k_threshold = k_worldWidth / 2;
LONG dx = p2.x - p1.x;
m_length = calcLength( m_x, m_y );
}
+ // \90³\8bK\89»\82³\82ê\82½\90¢\8aE\8dÀ\95W2\93_\82©\82ç\83x\83N\83g\83\8b\82ð\8eZ\8fo\82·\82é
+ //
+ // TODO: \82Å\82«\82ê\82ÎWorldMap\82É\8f\88\97\9d\82ð\88Ú\82µ\82½\82¢\81B
+ GVOVector( const GVONormalizedPoint & p1, const GVONormalizedPoint&p2 )
+ {
+ const float k_threshold = 0.5f;
+ float dx = p2.x() - p1.x();
+
+ if ( k_threshold < dx ) {
+ dx -= k_threshold;
+ }
+ else if ( dx < -k_threshold ) {
+ dx += k_threshold;
+ }
+ m_x = dx;
+ m_y = p2.y() - p1.y();
+ m_length = calcLength( m_x, m_y );
+ }
+
// \83x\83N\83g\83\8b\82Ìx\90¬\95ª
inline double x() const
{