当前位置: 首页>>代码示例>>C++>>正文


C++ GeoVector类代码示例

本文整理汇总了C++中GeoVector的典型用法代码示例。如果您正苦于以下问题:C++ GeoVector类的具体用法?C++ GeoVector怎么用?C++ GeoVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GeoVector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fixed

inline void
GlideComputerAirData::NextLegEqThermal(const NMEAInfo &basic,
                                       DerivedInfo &calculated,
                                       const ComputerSettings &settings)
{
  const GeoVector vector_remaining =
      calculated.task_stats.current_leg.vector_remaining;
  const GeoVector next_leg_vector =
      calculated.task_stats.current_leg.next_leg_vector;

  if(!next_leg_vector.IsValid() ||
      !vector_remaining.IsValid() ||
      !calculated.wind_available) {
    // Assign a negative value to invalidate the result
    calculated.next_leg_eq_thermal = fixed(-1);
    return;
  }

  // Calculate wind component on current and next legs
  const fixed wind_comp = calculated.wind.norm *
      (calculated.wind.bearing - vector_remaining.bearing).fastcosine();
  const fixed next_comp = calculated.wind.norm *
      (calculated.wind.bearing - next_leg_vector.bearing).fastcosine();

  calculated.next_leg_eq_thermal =
      settings.polar.glide_polar_task.GetNextLegEqThermal(wind_comp, next_comp);
}
开发者ID:StefanL74,项目名称:XCSoar,代码行数:27,代码来源:GlideComputerAirData.cpp

示例2: UpdateInfoBoxNextDistanceNominal

void
UpdateInfoBoxNextDistanceNominal(InfoBoxData &data)
{
  const Waypoint* way_point = protected_task_manager != NULL
    ? protected_task_manager->GetActiveWaypoint()
    : NULL;

  if (!way_point) {
    data.SetInvalid();
    return;
  }

  const NMEAInfo &basic = CommonInterface::Basic();
  const TaskStats &task_stats = CommonInterface::Calculated().task_stats;

  if (!task_stats.task_valid || !basic.location_available) {
      data.SetInvalid();
      return;
  }

  const GeoVector vector(basic.location, way_point->location);

  if (!vector.IsValid()) {
      data.SetInvalid();
      return;
  }

  // Set Value
  data.SetValueFromDistance(vector.distance);
  data.SetValueColor(task_stats.inside_oz ? 3 : 0);
  data.SetComment(vector.bearing);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:32,代码来源:Task.cpp

示例3: ToAircraftState

inline void
RouteComputer::TerrainWarning(const MoreData &basic,
                              DerivedInfo &calculated,
                              const RoutePlannerConfig &config)
{
  const AircraftState as = ToAircraftState(basic, calculated);

  const GlideResult& sol = calculated.task_stats.current_leg.solution_remaining;
  if (!sol.IsDefined()) {
    calculated.terrain_warning = false;
    return;
  }

  const AGeoPoint start (as.location, as.altitude);
  const RoughAltitude h_ceiling(std::max((int)basic.nav_altitude+500,
                                         (int)calculated.thermal_band.working_band_ceiling));
  // allow at least 500m of climb above current altitude as ceiling, in case
  // there are no actual working band stats.
  GeoVector v = sol.vector;
  if (v.distance > fixed(200000))
    /* limit to reasonable distances (200km max.) to avoid overflow in
       GeoVector::EndPoint() */
    v.distance = fixed(200000);

  if (terrain) {
    if (sol.IsDefined()) {
      const AGeoPoint dest(v.EndPoint(start), sol.min_arrival_altitude);
      bool dirty = route_clock.CheckAdvance(basic.time);

      if (!dirty) {
        dirty =
          calculated.common_stats.active_taskpoint_index != last_active_tp ||
          calculated.common_stats.task_type != last_task_type;
        if (dirty) {
          // restart clock
          route_clock.CheckAdvance(basic.time);
          route_clock.Reset();
        }
      }

      last_task_type = calculated.common_stats.task_type;
      last_active_tp = calculated.common_stats.active_taskpoint_index;

      if (dirty) {
        protected_route_planner.SolveRoute(dest, start, config, h_ceiling);
        calculated.planned_route = route_planner.GetSolution();

        calculated.terrain_warning =
          route_planner.Intersection(start, dest,
                                     calculated.terrain_warning_location);
      }
      return;
    } else {
      protected_route_planner.SolveRoute(start, start, config, h_ceiling);
      calculated.planned_route = route_planner.GetSolution();
    }
  }
  calculated.terrain_warning = false;
}
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:59,代码来源:RouteComputer.cpp

示例4: ray

void 
Airspaces::visit_intersecting(const GeoPoint &loc, 
                              const GeoVector &vec,
                              AirspaceIntersectionVisitor& visitor) const
{
  FlatRay ray(task_projection.project(loc), 
              task_projection.project(vec.end_point(loc)));

  GeoPoint c = vec.mid_point(loc);
  Airspace bb_target(c, task_projection);
  int mrange = task_projection.project_range(c, vec.Distance / 2);
  IntersectingAirspaceVisitorAdapter adapter(loc, vec, ray, visitor);
  airspace_tree.visit_within_range(bb_target, -mrange, adapter);

#ifdef INSTRUMENT_TASK
  n_queries++;
#endif
}
开发者ID:galippi,项目名称:xcsoar,代码行数:18,代码来源:Airspaces.cpp

示例5: AddSpiralWaypoints

static void
AddSpiralWaypoints(Waypoints &waypoints,
                   const GeoPoint &center = GeoPoint(Angle::Degrees(51.4),
                                                     Angle::Degrees(7.85)),
                   Angle angle_start = Angle::Degrees(0),
                   Angle angle_step = Angle::Degrees(15),
                   fixed distance_start = fixed(0),
                   fixed distance_step = fixed(1000),
                   fixed distance_max = fixed(150000))
{
  assert(positive(distance_step));

  for (unsigned i = 0;; ++i) {
    GeoVector vector;
    vector.distance = distance_start + distance_step * i;
    if (vector.distance > distance_max)
      break;

    vector.bearing = angle_start + angle_step * i;

    Waypoint waypoint;
    waypoint.location = vector.EndPoint(center);
    waypoint.original_id = i;
    waypoint.elevation = fixed(i * 10 - 500);

    StaticString<256> buffer;

    if (i % 7 == 0) {
      buffer = _T("Airfield");
      waypoint.type = Waypoint::Type::AIRFIELD;
    } else if (i % 3 == 0) {
      buffer = _T("Field");
      waypoint.type = Waypoint::Type::OUTLANDING;
    } else
      buffer = _T("Waypoint");

    buffer.AppendFormat(_T(" #%d"), i + 1);
    waypoint.name = buffer;

    waypoints.Append(std::move(waypoint));
  }

  waypoints.Optimise();
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:44,代码来源:TestWaypoints.cpp

示例6: LocationMapItem

void
MapItemListBuilder::AddLocation(const NMEAInfo &basic,
                                const RasterTerrain *terrain)
{
  if (list.full())
    return;

  GeoVector vector;
  if (basic.location_available)
    vector = basic.location.DistanceBearing(location);
  else
    vector.SetInvalid();

  double elevation = LocationMapItem::UNKNOWN_ELEVATION;
  if (terrain != nullptr)
    elevation = terrain->GetTerrainHeight(location)
      .ToDouble(LocationMapItem::UNKNOWN_ELEVATION);

  list.append(new LocationMapItem(vector, elevation));
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:20,代码来源:Builder.cpp

示例7: ivisitor

void
AirspaceXSRenderer::Draw(Canvas &canvas, const ChartRenderer &chart,
                         const Airspaces &database, const GeoPoint &start,
                         const GeoVector &vec, const AircraftState &state) const
{
  canvas.Select(*look.name_font);

  // Create IntersectionVisitor to render to the canvas
  AirspaceIntersectionVisitorSlice ivisitor(
      canvas, chart, settings, look, start, state);

  // Call visitor with intersecting airspaces
  database.VisitIntersecting(start, vec.EndPoint(start), ivisitor);
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:14,代码来源:AirspaceXSRenderer.cpp

示例8: sorter

AirspaceIntersectionVector
AirspaceCircle::intersects(const GeoPoint& start, const GeoVector &vec) const
{
  const GeoPoint end = vec.end_point(start);
  AirspaceIntersectSort sorter(start, end, *this);

  const fixed f_radius = m_task_projection->fproject_range(m_center, m_radius);
  const FlatPoint f_center = m_task_projection->fproject(m_center);
  const FlatPoint f_start = m_task_projection->fproject(start);
  const FlatPoint f_end = m_task_projection->fproject(end);
  const FlatLine line(f_start, f_end);

  if (inside(start))
    sorter.add(fixed_zero, start);

  FlatPoint f_p1, f_p2;
  if (line.intersect_circle(f_radius, f_center, f_p1, f_p2)) {
    const fixed mag = line.mag_sq();
    if (positive(mag)) {
      fixed inv_mag = -fixed_one;
      const fixed t1 = FlatLine(f_start, f_p1).dot(line);
      const fixed t2 = (f_p1 == f_p2) ?
                       -fixed_one : FlatLine(f_start, f_p2).dot(line);

      const bool in_range = (t1 < mag) || (t2 < mag);
      // if at least one point is within range, capture both points

      if ((t1 >= fixed_zero) && in_range) {
        if (negative(inv_mag))
          inv_mag = fixed_one / mag;

        sorter.add(t1 * inv_mag, m_task_projection->funproject(f_p1));
      }

      if ((t2 >= fixed_zero) && in_range) {
        if (negative(inv_mag))
          inv_mag = fixed_one / mag;

        sorter.add(t2 * inv_mag, m_task_projection->funproject(f_p2));
      }
    }
  }

  return sorter.all();
}
开发者ID:Plantain,项目名称:XCSoar,代码行数:45,代码来源:AirspaceCircle.cpp

示例9: ray

AirspaceIntersectionVector
AirspacePolygon::intersects(const GeoPoint& start, 
                            const GeoVector &vec) const
{
  const GeoPoint end = vec.end_point(start);
  const FlatRay ray(m_task_projection->project(start),
                    m_task_projection->project(end));

  AirspaceIntersectSort sorter(start, end, *this);

  for (SearchPointVector::const_iterator it= m_border.begin();
       it+1 != m_border.end(); ++it) {

    const FlatRay r_seg(it->get_flatLocation(), 
                        (it+1)->get_flatLocation());

    const fixed t = ray.intersects(r_seg);
    
    if (t>=fixed_zero) {
      sorter.add(t, m_task_projection->unproject(ray.parametric(t)));
    }
  }
  return sorter.all();
}
开发者ID:Plantain,项目名称:XCSoar,代码行数:24,代码来源:AirspacePolygon.cpp

示例10: fabs

bool ShpReader::SetupVectorScaling(VectorMapModelPtr vectorMapModel, ProgressDlgPtr progressDlg)
{
	double minX,minY,maxX,maxY;
	double aspect,width,height,scaleFactor;
	if ( App::Inst().GetLayerTreeController()->GetNumMapLayers() >0 )
	{
		MapControllerPtr mapController= App::Inst().GetLayerTreeController()->GetLayerTreeModel()->GetStudy(0)->GetMapLayer(0)->GetMapController();
		FileHeader* header=mapController->GetMapModel()->GetHeader();
		minX=header->projExtents.x;
		maxX=header->projExtents.dx;
		minY=header->projExtents.y;
		maxY=header->projExtents.dy;
		aspect = header->projExtents.Height() / header->projExtents.Width();		
		width = 2.0;
		height = 2.0*aspect;
		scaleFactor = 2.0 / header->projExtents.Width();
	}
	else{
		minX=vectorMapModel->GetVectorBoundary_MinX();
		minY=vectorMapModel->GetVectorBoundary_MinY();
		maxX=vectorMapModel->GetVectorBoundary_MaxX();
		maxY=vectorMapModel->GetVectorBoundary_MaxY();		
		aspect = fabs((maxY-minY) / (maxX-minX));
		width = 2.0;
		height = 2.0*aspect;
		scaleFactor = 2.0 / fabs(maxX-minX);
	}

	double scaledextent_minX= -1.0f + 2*((vectorMapModel->GetVectorBoundary_MinX() - minX) / fabs(maxX-minX));
	double scaledextent_minY = (1.0f + -2*((vectorMapModel->GetVectorBoundary_MinY() - minY) / fabs(maxY-minY)))*aspect;
	double scaledextent_maxX= -1.0f + 2*((vectorMapModel->GetVectorBoundary_MaxX() - minX) / fabs(maxX-minX));
	double scaledextent_maxY = (1.0f + -2*((vectorMapModel->GetVectorBoundary_MaxY() - minY) / fabs(maxY-minY)))*aspect;

	vectorMapModel->SetAspect(aspect);
	vectorMapModel->SetVectorBoundary_ScaledMinX(scaledextent_minX);
	vectorMapModel->SetVectorBoundary_ScaledMinY(scaledextent_minY);
	vectorMapModel->SetVectorBoundary_ScaledMaxX(scaledextent_maxX);
	vectorMapModel->SetVectorBoundary_ScaledMaxY(scaledextent_maxY);
	

	for ( unsigned int currGeometry = 0; currGeometry < vectorMapModel->GetNumberOfGeometries(); currGeometry++ )
	{
		GeoVector* GeoVector = vectorMapModel->GetGeoVector( currGeometry );

		for ( unsigned int currPoint = 0; currPoint < GeoVector->GetNumberOfPoints(); currPoint++ )
		{
			GeoVector->pointX[currPoint] = -1.0f + 2*((GeoVector->pointX[currPoint] - minX) / fabs(maxX-minX));
			GeoVector->pointY[currPoint] = (1.0f + -2*((GeoVector->pointY[currPoint] - minY) / fabs(maxY-minY)))*aspect;
		}

		if(progressDlg)
		{
			if(!progressDlg->Update(int(50 + (float(currGeometry)/vectorMapModel->GetNumberOfGeometries())*50)))
				return false;
		}
	}
	
	
	

	return true;
}
开发者ID:BioinformaticsArchive,项目名称:gengis,代码行数:62,代码来源:ShpReader.cpp

示例11: OGRRegisterAll


//.........这里部分代码省略.........
			//    printf( "%s,", poFeature->GetFieldAsString(iField) );

			//ofs << poFeature->GetFieldAsString(iField) << ",";

			std::string metaData = poFeature->GetFieldAsString(iField);
			// do something with the meta data...
			//Log::Inst().Write(metaData);
		}
		count++;
		if(progressDlg)
		{
			if(!progressDlg->Update(int(50 + (float(count)/numFeatures)*50)))
				return false;
		}

		///////////////////////////////////////////////////
		// PHASE 2: Retrieve GEOMETRIES from the dataset //
		///////////////////////////////////////////////////
		OGRGeometry *poGeometry;
		poGeometry = poFeature->GetGeometryRef();

		// Move to the next feature in the set if no geometry present
		if( poGeometry == NULL )
		{
			OGRFeature::DestroyFeature( poFeature );
			continue;
		}

		OGRwkbGeometryType whatisit = poGeometry->getGeometryType();

		// Handle POINTS
		if ( wkbFlatten( poGeometry->getGeometryType() ) == wkbPoint )
		{
			GeoVector* geoVector = new GeoVector();
			OGRPoint *poPoint = (OGRPoint *) poGeometry;

			geoVector->SetGeometryType( wkbPoint );
			geoVector->SetNumberOfPoints( 1 );
			if(needProjection)
			{
				double x,y;
				x= poPoint->getX();
				y= poPoint->getY();
				if(!poTransform->Transform(1, &x, &y))
				{
					Log::Inst().Warning("(Warning) Failed to project vector map.");
					OGRDataset->DestroyDataSource(OGRDataset);
					return false;
				}
				
				// project and store the points
				geoVector->pointX[0] = x;
				geoVector->pointY[0] = y;

				if(x < minX) minX=x;
				if(y < minY) minY=y;
				if(x > maxX) maxX=x;
				if(y > maxY) maxY=y;
			}
			else 			
			{
				geoVector->pointX[0] = poPoint->getX();
				geoVector->pointY[0] = poPoint->getY();

			}
			vectorMapController->GetVectorMapModel()->AddGeoVector( geoVector );
开发者ID:BioinformaticsArchive,项目名称:gengis,代码行数:67,代码来源:ShpReader.cpp

示例12: l_task_index

static int
l_task_index(lua_State *L)
{
  const char *name = lua_tostring(L, 2);
  if (name == nullptr)
    return 0;
  else if (StringIsEqual(name, "bearing")) {
    const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
    const GeoVector &vector_remaining = task_stats.current_leg.vector_remaining;
    if (!task_stats.task_valid || !vector_remaining.IsValid() ||
        vector_remaining.distance <= 10) {
      return 0;
    }
    Lua::Push(L, vector_remaining.bearing);
  } else if (StringIsEqual(name, "bearing_diff")) {
      const NMEAInfo &basic = CommonInterface::Basic();
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
      const GeoVector &vector_remaining = task_stats.current_leg.vector_remaining;
      if (!basic.track_available || !task_stats.task_valid ||
          !vector_remaining.IsValid() || vector_remaining.distance <= 10) {
        return 0;
      }      
      Lua::Push(L, vector_remaining.bearing - basic.track);
  } else if (StringIsEqual(name, "radial")) {
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
      const GeoVector &vector_remaining = task_stats.current_leg.vector_remaining;
      if (!task_stats.task_valid || !vector_remaining.IsValid() ||
          vector_remaining.distance <= 10) {
        return 0;
      }
      Lua::Push(L, vector_remaining.bearing.Reciprocal());
  } else if (StringIsEqual(name, "next_distance")) {
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
      const GeoVector &vector_remaining = task_stats.current_leg.vector_remaining;
      if (!task_stats.task_valid || !vector_remaining.IsValid()) 
        return 0;
     
      Lua::Push(L, vector_remaining.distance);
  } else if (StringIsEqual(name, "next_distance_nominal")) {
      const auto way_point = protected_task_manager != nullptr
          ? protected_task_manager->GetActiveWaypoint() : NULL;

      if (!way_point) return 0;
      const NMEAInfo &basic = CommonInterface::Basic();
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;

      if (!task_stats.task_valid || !basic.location_available) return 0;

      const GeoVector vector(basic.location, way_point->location);

      if (!vector.IsValid()) return 0;
      Lua::Push(L, vector.distance);
  } else if (StringIsEqual(name, "next_ete")) {
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
      if (!task_stats.task_valid || !task_stats.current_leg.IsAchievable()) 
        return 0; 
      assert(task_stats.current_leg.time_remaining_now >= 0);

      Lua::Push(L, task_stats.current_leg.time_remaining_now);
  } else if (StringIsEqual(name, "next_eta")) {
      const auto &task_stats = CommonInterface::Calculated().task_stats;
      const BrokenTime &now_local = CommonInterface::Calculated().date_time_local;

      if (!task_stats.task_valid || !task_stats.current_leg.IsAchievable() ||
          !now_local.IsPlausible()) {
        return 0;
      }

      const BrokenTime t = now_local +
      unsigned(task_stats.current_leg.solution_remaining.time_elapsed);
      float time = t.hour + (float)(t.second/60);

      Lua::Push(L, time);
  } else if (StringIsEqual(name, "next_altitude_diff")) {    
      const auto &task_stats = CommonInterface::Calculated().task_stats;
      const auto &next_solution = task_stats.current_leg.solution_remaining;

      if (!task_stats.task_valid || !next_solution.IsAchievable())
        return 0;

      const auto &settings = CommonInterface::GetComputerSettings();
      auto altitude_difference = next_solution.SelectAltitudeDifference(settings.task.glide);
      Lua::Push(L, altitude_difference);
  } else if (StringIsEqual(name, "nextmc0_altitude_diff")) {
      const TaskStats &task_stats = CommonInterface::Calculated().task_stats;
      if (!task_stats.task_valid || !task_stats.current_leg.solution_mc0.IsAchievable())
        return 0;

      const auto &settings = CommonInterface::GetComputerSettings();
      auto altitude_difference = task_stats.current_leg.solution_mc0.SelectAltitudeDifference(settings.task.glide);
      Lua::Push(L, altitude_difference);
  } else if (StringIsEqual(name, "next_altitude_require")) {
      const auto &task_stats = CommonInterface::Calculated().task_stats;
      const auto &next_solution = task_stats.current_leg.solution_remaining;
      if (!task_stats.task_valid || !next_solution.IsAchievable()) 
        return 0;

      Lua::Push(L, next_solution.GetRequiredAltitude());
  } else if (StringIsEqual(name, "next_altitude_arrival")) {
      const auto &basic = CommonInterface::Basic();
//.........这里部分代码省略.........
开发者ID:Advi42,项目名称:XCSoar,代码行数:101,代码来源:Task.cpp

示例13: SetInvalid

 void SetInvalid() {
   vec.SetInvalid();
   start.SetInvalid();
 }
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:4,代码来源:CrossSectionRenderer.hpp


注:本文中的GeoVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。