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

📄 routelink_if.c

📁 本程序的功能是对导航数据中的道路情况数据进行整理
💻 C
字号:
/****************************************************************************
	FileName    :	routelink_if.c

	Date        :	2006.07.22

	Author      :	

	Copyright   :	
-----------------------------------------------------------------------------
	Modify History
	NO       Date           Modifier         Modified Contet

****************************************************************************/

/*-------------------------------------------------------------------------*/
/*																		   */
/*   Include File Section                                                  */
/*																		   */
/*-------------------------------------------------------------------------*/
#include <stdio.h>
#include <malloc.h>
#include "routelink_c.h"
#include "routelink_in_c.h"
#include "routelink_in_s.h"
#include "routelink_in_p.h"

/* Route link info search type definition								   */
#define		RTL_SRC_LNKID			( 1  )			/* By Link ID		   */
#define		RTL_SRC_DSPCLSNO		( 2  )			/* By Class No		   */
#define		RTL_SRC_BRCHNUM			( 3  )			/* By Cross number	   */
#define		RTL_SRC_ROADNAME		( 4  )			/* By Road name		   */
#define		RTL_SRC_INVALIDKIND		( 0  )			/* Invalid search type */

/***************************************************************************/
/*	RouteLink_Analyse													   */
/*	-----------------------------------------------------------------------*/
/*	Input:																   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Output:																   */
/*		RETURN				:	乮Normal乯RET_SUCCESS					   */
/*								乮Error乯 RET_FAILED					   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Outline:															   */
/*		Route link data analyse proc IF funciton.						   */
/*		This function will analyse the route link data in the file GTBL.dat*/
/*		and output the result into the file analyselink.dat.			   */
/*		You can also change the name of the file by changing the file	   */
/*		routelink_c.h.													   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Others:																   */
/*																		   */
/***************************************************************************/
int RouteLink_Analyse()
{
	int				iRet			= RET_SUCCESS;
	int				iReadBlockSize	= 0;	/* Size of file read buffer	   */
	int				iFileSize		= 0;	/* Size of file				   */
	int				iRoadLnkNum		= 0;	/* Number of Road Link Node	   */
	FILE*			pOrgFile		= NULL;	/* Route link info file handle */
	BYTE*			pbFileBuf		= NULL;	/* Buffer for read from file   */
	S_LNKTBL*		pstHeaderLnk	= NULL;	/* Header node pointer		   */
	S_LNKTBL_REC*	pstLnkRecArray	= NULL;	/* Array for Link info record  */


	/* Get the size	of route link data file				*/
	iFileSize = routelink_getfsize( RTL_ORGDAT_FILENAME );

	/* Open Route link data file						*/
	pOrgFile = fopen( RTL_ORGDAT_FILENAME, "rb" );
	if( NULL == pOrgFile )
	{
		printf( "Route link info file GTBL open failed!" );
		return RET_FAILED;
	}

	/* Malloc memory for buffer							*/
	if( iFileSize < FILEREAD_MAXSIZE )
	{
		iReadBlockSize = iFileSize;
	}
	else
	{
		iReadBlockSize = FILEREAD_MAXSIZE;
	}
	pbFileBuf = (BYTE*)malloc( iReadBlockSize );
	if( NULL == pbFileBuf )
	{
		fclose( pOrgFile );
		pOrgFile = NULL;

		return RET_FAILED;
	}

	/* Create a single link for recording the info of the route link data  */
	iRoadLnkNum = routelink_analyse_slinkcre( 
						pOrgFile, pbFileBuf, iReadBlockSize, &pstHeaderLnk );

	/* Link table -> Array(for the continuous area)						   */
	routelink_analyse_slink2array( pstHeaderLnk, iRoadLnkNum, &pstLnkRecArray );

	/* Free the link table 								*/
	routelink_analyse_slinkfree( &pstHeaderLnk, iRoadLnkNum );

	/* Analyse proc function executed(3 analyse methods aviable)		*/
	iRet = routelink_analyse_slinkanalyse( pstLnkRecArray, iRoadLnkNum );

	/* Move Route link data into consecutive memory for writting into file */
	routelink_analyse_resultoutput( pstLnkRecArray, iRoadLnkNum );

	/* Free the array for link data info record	*/
	routelink_analyse_freearray( &pstLnkRecArray );

	free( pbFileBuf );
	pbFileBuf = NULL;

	fclose( pOrgFile );
	pOrgFile = NULL;

	return RET_SUCCESS;
}


/***************************************************************************/
/*	RouteLink_Src														   */
/*	-----------------------------------------------------------------------*/
/*	Input:																   */
/*		H_ROUTELINK			:	Route link class handle					   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Output:																   */
/*		RETURN				:	乮Normal乯RET_SUCCESS					   */
/*								乮Error乯 RET_FAILED					   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Outline:															   */
/*		Route link search proc IF funciton.								   */
/*		This function will search the data by the different Key specified  */
/*		by the user.The result will be output into the file with the name  */
/*		searchresultXXX.txt. 											   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Others:																   */
/*																		   */
/***************************************************************************/
int RouteLink_Src()
{
	int				iSrcType		= 0;	/* Search type selected by user*/
	int				iRet			= RET_SUCCESS;
	FILE*			pOrgFile		= NULL;	/* Route link info file handle */
	int				iResult			= 0;


	/* Oen Route link data file 							*/
	pOrgFile = fopen( RTL_ORGDAT_FILENAME, "rb" );
	if( NULL == pOrgFile )
	{
		printf( "Route link info file GTBL open failed!" );
		return RET_FAILED;
	}

	/* Prompt user to select Route Link Info search type	*/
	printf( "Please select the search type!>>>>>>>>\n" );
	printf( "1	:Search by Link ID.\n" );
	printf( "2	:Search by Cross link displayed class No.\n" );
	printf( "3	:Search by Branch number(over the specified number).\n" );
	printf( "4	:Search by Road name.\n" );
	printf( "Other	:Quit.\n" );

	/* Read the user's selection from key buffer			*/
	iResult = scanf( "%d", &iSrcType );
	while( iResult <= 0 )
	{
		printf( "Invalid input! Please input again:\n");
		fflush( stdin );
		iResult = scanf( "%d", &iSrcType);
	}

	/* Call different search proc function by the search type	*/
	switch( iSrcType )
	{
	case RTL_SRC_LNKID:		/* Searching by Link ID				*/
		iRet = routelink_src_lnkid( pOrgFile );
		break;

	case RTL_SRC_DSPCLSNO:	/* Searching by Class No.			*/
		iRet = routelink_src_clsno( pOrgFile );
		break;

	case RTL_SRC_BRCHNUM:	/* Searching by Branch Number		*/
		iRet = routelink_src_branch( pOrgFile );
		break;

	case RTL_SRC_ROADNAME:	/* Searching by Road Name			*/
		iRet = routelink_src_roadname( pOrgFile );
		break;

	default:
		break;
	}

	/* File close								*/
	fclose( pOrgFile );
	pOrgFile = NULL;

	return RET_SUCCESS;
}

/***************************************************************************/
/*	RouteLink_Update													   */
/*	-----------------------------------------------------------------------*/
/*	Input:																   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Output:																   */
/*		RETURN				:	乮Normal乯RET_SUCCESS					   */
/*								乮Error乯 RET_FAILED					   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Outline:															   */
/*		Route link search proc IF funciton.								   */
/*		This function will update the Route link data in the data file.	   */
/*		Both the original data file and the analyse data file will be      */
/*		updated. If the analyse data file does not exist, it will be       */
/*		created by the original data file(after being updated)			   */
/*																		   */
/*	-----------------------------------------------------------------------*/
/*	Others:																   */
/*																		   */
/***************************************************************************/
int RouteLink_Update()
{
	int				iRet			= RET_SUCCESS;


	/* Update Link Data by cycling	*/
	iRet = routelink_upd_cycupdate();

	return iRet;
}

/*	End of file------------------------------------------------------------*/

⌨️ 快捷键说明

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