/// <summary> /// 根据里程信息获取采样值,换算为采样点个数,同时获取坐标位置 /// </summary> /// <param name="mileage">里程,单位为米</param> /// <param name="locationPostion"></param> /// <returns>采样点个数</returns> public long GetLocationSampleCount(float mileage, ref long locationPostion) { if (IsLoadIndex) { //if (CitFile.iKmInc == 0) //{ // Milestone stone= MileageFix.CalcMilestoneByFixedMilestone(mileage); // //Milestone stone = _allStone.FindLast(p => p.GetMeter() <= mileage); // if (stone != null) // { // locationPostion = stone.mFilePosition; // } // else // { // locationPostion = -1; // } //} //else //{ // //Milestone stone = _allStone.FindLast(p => p.GetMeter() >= mileage); // long postion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, mileage, true); // if (postion != -1) // { // locationPostion = postion; // } // else // { // locationPostion = -1; // } //} Milestone stone = MileageFix.CalcMilestoneByFixedMilestone(mileage); if (stone != null) { locationPostion = stone.mFilePosition; } else { locationPostion = -1; } } else { locationPostion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, mileage, true); } if (locationPostion != -1) { return(GetLocationSampleCount(locationPostion)); } return(-1); }
/// <summary> /// 导出CIT文件 /// </summary> /// <param name="filePath">文件路径</param> /// <param name="filePath">导出路径</param> /// <param name="startMileage">起始里程(单位:米)</param> /// <param name="endMileage">结束里程(单位:米)</param> /// <returns></returns> public string ExportOnlyCITFile(string filePath, double startMileage, double endMileage) { try { if (_citFile != null) { long startPostion = -1; long endPostion = -1; startPostion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, (float)startMileage, true); endPostion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, (float)endMileage, true); if (startPostion == -1 || endPostion == -1) { return(""); } if (CitFileProcess.WriteCitFile(filePath, _citFile, CitFileProcess.GetChannelDefinitionList(_citFilePath), "")) { if (startPostion > endPostion) { long temp = startPostion; startPostion = endPostion; endPostion = temp; } long sampleCount = CitFileProcess.GetSampleCountByRange(_citFilePath, startPostion, endPostion); int sampleNumber = 5000; if (sampleCount > sampleNumber) { long pageCount = (sampleCount / sampleNumber); long pageEndPostion = 0; for (int i = 0; i < pageCount; i++) { List <double[]> channelData = CitFileProcess.GetAllChannelDataInRange(_citFilePath, startPostion, sampleNumber, ref pageEndPostion); startPostion = pageEndPostion; CitFileProcess.WriteCitChannelData(filePath, channelData); } if (pageEndPostion < endPostion) { List <double[]> channelData = CitFileProcess.GetAllChannelDataInRange(_citFilePath, startPostion, endPostion); CitFileProcess.WriteCitChannelData(filePath, channelData); } } else { List <double[]> channelData = CitFileProcess.GetAllChannelDataInRange(_citFilePath, startPostion, endPostion); CitFileProcess.WriteCitChannelData(filePath, channelData); } if (CitFileProcess.SetKmFrom(filePath, (float)startMileage / 1000) && CitFileProcess.SetKmTo(filePath, (float)endMileage / 1000)) { return(filePath); } } } return(string.Empty); } catch (Exception ex) { throw ex; } }