⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 garmintypes.cpp

📁 garmin 协议处理范例: 处理了 0183协议 处理了 gps的专有格式等
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	{0x01, "Large urban area (>200K)",     & g_hbrSettlement,    & g_hpenNull,      },
	{0x02, "Medium urban area (50K-200K)", & g_hbrSettlement,    & g_hpenNull,      },
	{0x03, "Small urban area (<50K)",      & g_hbrSettlement,    & g_hpenNull,      },

	{0x04, "Military base",          & g_hbrGray,          & g_hpenBlackThin, },
	{0x05, "Parking lot",            & g_hbrGray,          & g_hpenBlackThin, },
	{0x06, "Parking garage",         & g_hbrGray,          & g_hpenBlackThin, },
	{0x07, "Airport",                & g_hbrGray,          & g_hpenBlackThin, },
	{0x08, "Shopping center",        & g_hbrHousing,       & g_hpenNull,      },
	{0x09, "Marina",                 & g_hbrHousing,       & g_hpenNull,      },
	{0x0a, "University/College",     & g_hbrHousing,       & g_hpenNull,      },
	{0x0b, "Hospital",               & g_hbrHousing,       & g_hpenNull,      },
	{0x0c, "Industrial complex",     & g_hbrGray,          & g_hpenBlackThin, },
	{0x0d, "Reservation",            & g_hbrForest,        & g_hpenNull,      },
	{0x0e, "Airport runway",         & g_hbrLtGray,        & g_hpenBlackThin, },
	{0x13, "Man-made area",          & g_hbrGray,          & g_hpenBlackThin, },

	{0x14, "National park",          & g_hbrForest,        & g_hpenNull,      },
	{0x15, "National park",          & g_hbrForest,        & g_hpenNull,      },
	{0x16, "National park",          & g_hbrForest,        & g_hpenNull,      },
	{0x17, "City park",              & g_hbrCityPark,      & g_hpenNull,      },

	{0x18, "Golf course",            & g_hbrUnknown,       & g_hpenUnknown,   },
	{0x19, "Sports complex",         & g_hbrGray,          & g_hpenBlackThin, },
	{0x1a, "Cemetery",               & g_hbrCemetery,      & g_hpenBlackThin, },

	{0x1e, "State park",             & g_hbrForest,        & g_hpenNull,      },
	{0x1f, "State park",             & g_hbrForest,        & g_hpenNull,      },
	{0x20, "State park",             & g_hbrForest,        & g_hpenNull,      },

	{0x28, "Sea/Ocean",              & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x29, "Blue-Unknown",           & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},

	{0x32, "Sea",                    & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},

	{0x3b, "Blue-Unknown",              & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x3c, "Large lake (250-600 km2)",  & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x3d, "Large lake (77-250 km2)",   & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x3e, "Medium lake (25-77 km2)",   & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x3f, "Medium lake (11-25 km2)",   & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x40, "Small lake (0.25-11 km2)",  & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x41, "Small lake (<0.25 km2)",    & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x42, "Major lake (>3.3 tkm2)",    & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x43, "Major lake (1.1-3.3 tkm2)", & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x44, "Large lake (0.6-1.1 tkm2)", & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},

	{0x45, "Blue-Unknown",              & g_hbrWater,         & g_hpenCoast,     & g_LakeLabel},
	{0x46, "Major river (>1 km)",       & g_hbrWater,         & g_hpenCoast,     & g_RiverLabel},
	{0x47, "Large river (200 m-1 km)",  & g_hbrWater,         & g_hpenCoast,     & g_RiverLabel},
	{0x48, "Medium river (40-200 m)",   & g_hbrWater,         & g_hpenCoast,     & g_RiverLabel},
	{0x49, "Small river (<40 m)",       & g_hbrWater,         & g_hpenCoast,     & g_RiverLabel},

	{0x4a, "Definition area",        & g_hbrNull,          & g_hpenNull},
	{0x4b, "Background",             & g_hbrNull,          & g_hpenNull},

	{0x4c, "Intermittent water",     & g_hbrDryWater,      & g_hpenDryWater,  & g_LakeLabel},

	{0x4d, "Glacier",                & g_hbrGlacier,       & g_hpenNull,      },
	{0x4e, "Orchard/plantation",     & g_hbrOrchard,       & g_hpenNull,      },
	{0x4f, "Scrub",                  & g_hbrScrub,         & g_hpenNull,      },
	{0x50, "Forest",                 & g_hbrForest,        & g_hpenNull,      },
	{0x51, "Wetland/swamp",          & g_hbrMarches,       & g_hpenNull,      & g_LakeLabel},
	{0x52, "Tundra",                 & g_hbrTundra,        & g_hpenNull,      },
	{0x53, "Sand/tidal/mud flat",    & g_hbrSandFlat,      & g_hpenNull,      },
};

void InitGarminTypes (std::vector<type_desc_t> & _types) {
	//
	//
	//
	_types.push_back (g_tdUnknown);

	// Prepare POIs.
	size_t cPOI;
	for (cPOI = 0; cPOI < sizeof (g_POIs)/sizeof (g_POIs [0]); ++ cPOI) {
		const POI_desc_t & d = g_POIs [cPOI];

		_types.push_back (type_desc_t ());
		type_desc_t & td = _types.back ();
		::memset (& td, 0, sizeof (td));

		td.ushType        = (USHORT (d.btPointCode) << 8) + d.btPOISubcodeMin;
		td.Kind           = rkPoint;
		td.ulType2        = td.ulType + (d.btPOISubcodeMax == 0 ? 0 : d.btPOISubcodeMax - d.btPOISubcodeMin);

		td.strTypeName    = d.strTypeName;
		td.phCursor       = d.phCursor;
		td.phBrush        = NULL;
		td.phPen          = NULL;
		td.phPen2         = NULL;

		const label_desc_t * const pLD = d.pLabelDesc ? d.pLabelDesc : & g_DefLabel;
		td.phFont         = pLD->phFont;
		td.colText        = pLD->colText;
		td.pfPrepareLabel = pLD->pfPrepareLabel;
		td.pfDrawLabel    = pLD->pfDrawLabel;
	}

	// Prepare marine POIs.
	for (cPOI = 0; cPOI < sizeof (g_MarinePOIs)/sizeof (g_MarinePOIs [0]); ++ cPOI) {
		const POI_desc_t & d = g_MarinePOIs [cPOI];

		for (BYTE btPointCode = 0x16; btPointCode <= 0x1b; ++ btPointCode) {
			_types.push_back (type_desc_t ());
			type_desc_t & td = _types.back ();
			::memset (& td, 0, sizeof (td));

			td.ushType        = (USHORT (btPointCode) << 8) + d.btPOISubcodeMin;
			td.Kind           = rkPoint;
			td.ulType2        = td.ulType;

			td.strTypeName    = d.strTypeName;
			td.phCursor       = d.phCursor;
			td.phBrush        = NULL;
			td.phPen          = NULL;
			td.phPen2         = NULL;

			const label_desc_t * const pLD = d.pLabelDesc ? d.pLabelDesc : & g_DefLabel;
			td.phFont         = pLD->phFont;
			td.colText        = pLD->colText;
			td.pfPrepareLabel = pLD->pfPrepareLabel;
			td.pfDrawLabel    = pLD->pfDrawLabel;
		}
	}

	// Prepare polylines.
	for (size_t cPolyline = 0; cPolyline < sizeof (g_Polylines)/sizeof (g_Polylines [0]); ++ cPolyline) {
		const polyline_desc_t & d = g_Polylines [cPolyline];

		_types.push_back (type_desc_t ());
		type_desc_t & td = _types.back ();
		::memset (& td, 0, sizeof (td));

		td.ushType        = d.btCode;
		td.Kind           = rkPolyline;
		td.ulType2        = td.ulType;

		td.strTypeName    = d.strTypeName;
		td.phCursor       = NULL;
		td.phBrush        = NULL;
		td.phPen          = d.phPen;
		td.phPen2         = d.phPen2;

		const label_desc_t * const pLD = d.pLabelDesc ? d.pLabelDesc : & g_DefLabel;
		td.phFont         = pLD->phFont;
		td.colText        = pLD->colText;
		td.pfPrepareLabel = pLD->pfPrepareLabel;
		td.pfDrawLabel    = pLD->pfDrawLabel;
	}

	// Prepare polygons.
	for (size_t cPolygon = 0; cPolygon < sizeof (g_Polygons)/sizeof (g_Polygons [0]); ++ cPolygon) {
		const polygon_desc_t & d = g_Polygons [cPolygon];

		_types.push_back (type_desc_t ());
		type_desc_t & td = _types.back ();
		::memset (& td, 0, sizeof (td));

		td.ushType        = d.btCode;
		td.Kind           = rkPolygon;
		td.ulType2        = td.ulType;

		td.strTypeName    = d.strTypeName;
		td.phCursor       = NULL;
		td.phBrush        = d.phBrush;
		td.phPen          = d.phPen;
		td.phPen2         = NULL;

		const label_desc_t * const pLD = d.pLabelDesc ? d.pLabelDesc : & g_CenteredLabel;
		td.phFont         = pLD->phFont;
		td.colText        = pLD->colText;
		td.pfPrepareLabel = pLD->pfPrepareLabel;
		td.pfDrawLabel    = pLD->pfDrawLabel;
	}

	// Make sure all types are sorted by code (as required by GetTypeDesc()).
	std::sort (_types.begin (), _types.end ());

	// Check type ranges for consistency.
	size_t cType;
	for (cType = 0; cType < _types.size () - 1; ++ cType) {
		type_desc_t & td0 = _types [cType];
		type_desc_t & td1 = _types [cType + 1];

		assert (td0.ulType <= td0.ulType2);
		assert (td0.ulType < td1.ulType);

		if (td0.ulType2 > td1.ulType2) {
			_types.insert (_types.begin () + cType + 2, type_desc_t ());
			type_desc_t & td2 = _types [cType + 2];
			td2 = td0;
			td2.ulType = td1.ulType2 + 1;
			td2.ulType2 = td0.ulType2;

			td0.ulType2 = td1.ulType - 1;
		}
	}
}

static std::vector<type_desc_t> g_types_impl;

static
void _InitGarminTypes () {
	//
	// Prepare Garmin-specific POI icons.
	//

	InitGarminTypes (g_types_impl);

	// NOTE: here is assumed that STL stores vector as plain array.
	g_tsGarmin.pTypes = & g_types_impl [0];
	g_tsGarmin.cTypes = g_types_impl.size ();

	g_tsGarmin.strID = "Garmin";
	g_tsGarmin.strDisplayName = "Garmin";

	g_tsGarmin.pfGetLatGrid  = GarminLatGrid;
	g_tsGarmin.pfRoundPoint  = GarminRoundPoint;
	g_tsGarmin.pfRoundPoints = GarminRoundPoints;
	g_tsGarmin.pfRoundRect   = GarminRoundRect;

	g_tsGarmin.pfIsCity       = Garmin_IsCity;
	g_tsGarmin.pfIsHwExit     = Garmin_IsHwExit;
	g_tsGarmin.pfIsRoad       = Garmin_IsRoad;
	g_tsGarmin.pfIsBackground = Garmin_IsBackground;
	g_tsGarmin.pfHasAddress   = Garmin_HasAddress;

	g_tsGarmin.dwFeatures = CTypeSet::tsfHasCopyright | CTypeSet::tsfHasElevationUnits;
}

static
void _DestroyGarminTypes () {}

CTypeSet g_tsGarmin (_InitGarminTypes, _DestroyGarminTypes);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -