text:
#include "routing/routing_tests/index_graph_tools.hpp"

#include "testing/testing.hpp"

#include "routing/geometry.hpp"

#include "routing/base/routing_result.hpp"

#include "routing/routing_helpers.hpp"

#include "base/assert.hpp"
#include "base/math.hpp"

#include <unordered_map>

#include "3party/opening_hours/opening_hours.hpp"

using namespace std;

namespace routing_test
{
namespace
{
double constexpr kEpsilon = 1e-6;

template <typename Graph>
Graph & GetGraph(unordered_map<NumMwmId, unique_ptr<Graph>> const & graphs, NumMwmId mwmId)
{
  auto it = graphs.find(mwmId);
  CHECK(it != graphs.end(), ("Not found graph for mwm", mwmId));
  return *it->second;
}

template <typename Graph>
void AddGraph(unordered_map<NumMwmId, unique_ptr<Graph>> & graphs, NumMwmId mwmId,
              unique_ptr<Graph> graph)
{
  auto it = graphs.find(mwmId);
  CHECK(it == graphs.end(), ("Already contains graph for mwm", mwmId));
  graphs[mwmId] = move(graph);
}
}  // namespace

// RestrictionTest ---------------------------------------------------------------------------------
void RestrictionTest::SetStarter(FakeEnding const & start, FakeEnding const & finish)
{
  CHECK(m_graph != nullptr, ("Init() was not called."));
  m_starter = MakeStarter(start, finish, *m_graph);
}

void RestrictionTest::SetRestrictions(RestrictionVec && restrictions)
{
  m_graph->GetIndexGraphForTests(kTestNumMwmId).SetRestrictions(move(restrictions));
}

void RestrictionTest::SetUTurnRestrictions(vector<RestrictionUTurn> && restrictions)
{
  m_graph->GetIndexGraphForTests(kTestNumMwmId).SetUTurnRestrictions(move(restrictions));
}

// NoUTurnRestrictionTest --------------------------------------------------------------------------
void NoUTurnRestrictionTest::Init(unique_ptr<SingleVehicleWorldGraph> graph)
{
  m_graph = make_unique<WorldGraphForAStar>(move(graph));
}

void NoUTurnRestrictionTest::SetRestrictions(RestrictionVec && restrictions)
{
  auto & indexGraph = m_graph->GetWorldGraph().GetIndexGraph(kTestNumMwmId);
  indexGraph.SetRestrictions(move(restrictions));
}

void NoUTurnRestrictionTest::SetNoUTurnRestrictions(vector<RestrictionUTurn> && restrictions)
{
  auto & indexGraph = m_graph->GetWorldGraph().GetIndexGraph(kTestNumMwmId);
  indexGraph.SetUTurnRestrictions(move(restrictions));
}

void NoUTurnRestrictionTest::TestRouteGeom(Segment const & start, Segment const & finish,
                                           AlgorithmForWorldGraph::Result expectedRouteResult,
                                           vector<m2::PointD> const & expectedRouteGeom)
{
  AlgorithmForWorldGraph algorithm;
  AlgorithmForWorldGraph::ParamsForTests<> params(*m_graph, start, finish,
                                                  nullptr /* prevRoute */);

  RoutingResult<Segment, RouteWeight> routingResult;
  auto const resultCode = algorithm.FindPathBidirectional(params, routingResult);

  TEST_EQUAL(resultCode, expectedRouteResult, ());
  for (size_t i = 0; i < routingResult.m_path.size(); ++i)
  {
    static auto constexpr kEps = 1e-3;
    auto const point = m_graph->GetWorldGraph().GetPoint(routingResult.m_path[i], true /* forward */);
    if (!base::AlmostEqualAbs(mercator::FromLatLon(point), expectedRouteGeom[i], kEps))
    {
      TEST(false, ("Coords missmated at index:", i, "expected:", expectedRouteGeom[i],
                   "received:", point));
    }
  }
}

// ZeroGeometryLoader ------------------------------------------------------------------------------
void ZeroGeometryLoader::Load(uint32_t /* featureId */, routing::RoadGeometry & road)
{
  // Any valid road will do.
  auto const points = routing::RoadGeometry::Points({{0.0, 0.0}, {0.0, 1.0}});
  road = RoadGeometry(true /* oneWay */, 1.0 /* weightSpeedKMpH */, 1.0 /* etaSpeedKMpH */, points);
}

// TestIndexGraphLoader ----------------------------------------------------------------------------
IndexGraph & TestIndexGraphLoader::GetIndexGraph(NumMwmId mwmId)
{
  return GetGraph(m_graphs, mwmId);
}

void TestIndexGraphLoader::Clear() { m_graphs.clear(); }

void TestIndexGraphLoader::AddGraph(NumMwmId mwmId, unique_ptr<IndexGraph> graph)
{
  routing_test::AddGraph(m_graphs, mwmId, move(graph));
}

// TestTransitGraphLoader ----------------------------------------------------------------------------
TransitGraph & TestTransitGraphLoader::GetTransitGraph(NumMwmId mwmId, IndexGraph &)
{
  return GetGraph(m_graphs, mwmId);
}

void TestTransitGraphLoader::Clear() { m_graphs.clear(); }

void TestTransitGraphLoader::AddGraph(NumMwmId mwmId, unique_ptr<TransitGraph> graph)
{
  routing_test::AddGraph(m_graphs, mwmId, move(graph));
}

// WeightedEdgeEstimator --------------------------------------------------------------
double WeightedEdgeEstimator::CalcSegmentWeight(Segment const & segment,
                                                RoadGeometry const & /* road */,
                                                EdgeEstimator::Purpose /* purpose */) const
{
  auto const it = m_segmentWeights.find(segment);
  CHECK(it != m_segmentWeights.cend(), ());
  return it->second;
}

double WeightedEdgeEstimator::GetUTurnPenalty(Purpose purpose) const { return 0.0; }
double WeightedEdgeEstimator::GetFerryLandingPenalty(Purpose purpose) const { return 0.0; }

// TestIndexGraphTopology --------------------------------------------------------------------------
TestIndexGraphTopology::TestIndexGraphTopology(uint32_t numVertices) : m_numVertices(numVertices) {}

void TestIndexGraphTopology::AddDirectedEdge(Vertex from, Vertex to, double weight)
{
  AddDirectedEdge(m_edgeRequests, from, to, weight);
}

void TestIndexGraphTopology::SetEdgeAccess(Vertex from, Vertex to, RoadAccess::Type type)
{
  for (auto & r : m_edgeRequests)
  {
    if (r.m_from == from && r.m_to == to)
    {
      r.m_accessType = type;
      return;
    }
  }
  CHECK(false, ("Cannot set access for edge that is not in the graph", from, to));
}

void TestIndexGraphTopology::SetEdgeAccessConditional(Vertex from, Vertex to, RoadAccess::Type type,
                                                      string const & condition)
{
  for (auto & r : m_edgeRequests)
  {
    if (r.m_from == from && r.m_to == to)
    {
      osmoh::OpeningHours openingHours(condition);
      CHECK(openingHours.IsValid(), (condition));
      r.m_accessConditionalType.Insert(type, move(openingHours));
      return;
    }
  }
  CHECK(false, ("Cannot set access for edge that is not in the graph", from, to));
}

void TestIndexGraphTopology::SetVertexAccess(Vertex v, RoadAccess::Type type)
{
  bool found = false;
  for (auto & r : m_edgeRequests)
  {
    if (r.m_from == v)
    {
      r.m_fromAccessType = type;
      found = true;
    }
    else if (r.m_to == v)
    {
      r.m_toAccessType = type;
      found = true;
    }

    if (found)
      break;
  }
  CHECK(found, ("Cannot set access for vertex that is not in the graph", v));
}

void TestIndexGraphTopology::SetVertexAccessConditional(Vertex v, RoadAccess::Type type,
                                                        string const & condition)
{
  osmoh::OpeningHours openingHours(condition);
  CHECK(openingHours.IsValid(), (condition));

  bool found = false;
  for (auto & r : m_edgeRequests)
  {
    if (r.m_from == v)
    {
      r.m_fromAccessConditionalType.Insert(type, move(openingHours));
      found = true;
    }
    else if (r.m_to == v)
    {
      r.m_toAccessConditionalType.Insert(type, move(openingHours));
      found = true;
    }

    if (found)
      break;
  }
  CHECK(found, ("Cannot set access for vertex that is not in the graph", v));
}

bool TestIndexGraphTopology::FindPath(Vertex start, Vertex finish, double & pathWeight,
                                      vector<Edge> & pathEdges) const
{
  CHECK_LESS(start, m_numVertices, ());
  CHECK_LESS(finish, m_numVertices, ());

  if (start == finish)
  {
    pathWeight = 0.0;
    pathEdges.clear();
    return true;
  }

  auto edgeRequests = m_edgeRequests;
  // Edges of the index graph are segments, so we need a loop at finish
  // for the end of our path and another loop at start for the bidirectional search.
  auto const startFeatureId = static_cast<uint32_t>(edgeRequests.size());
  AddDirectedEdge(edgeRequests, start, start, 0.0);
  // |startSegment| corresponds to edge from |start| to |start| which has featureId |startFeatureId|
  // and the only segment with segmentIdx |0|. It is a loop so direction does not matter.
  auto const startSegment = Segment(kTestNumMwmId, startFeatureId, 0 /* segmentIdx */,
                                    true /* forward */);

  auto const finishFeatureId = static_cast<uint32_t>(edgeRequests.size());
  AddDirectedEdge(edgeRequests, finish, finish, 0.0);
  // |finishSegment| corresponds to edge from |finish| to |finish| which has featureId |finishFeatureId|
  // and the only segment with segmentIdx |0|. It is a loop so direction does not matter.
  auto const finishSegment = Segment(kTestNumMwmId, finishFeatureId, 0 /* segmentIdx */,
                                     true /* forward */);

  Builder builder(m_numVertices);
  builder.SetCurrentTimeGetter(m_currentTimeGetter);
  builder.BuildGraphFromRequests(edgeRequests);
  auto worldGraph = builder.PrepareIndexGraph();
  CHECK(worldGraph != nullptr, ());

  AlgorithmForWorldGraph algorithm;

  WorldGraphForAStar graphForAStar(move(worldGraph));

  AlgorithmForWorldGraph::ParamsForTests<> params(graphForAStar, startSegment, finishSegment,
                                                  nullptr /* prevRoute */);
  RoutingResult<Segment, RouteWeight> routingResult;
  auto const resultCode = algorithm.FindPathBidirectional(params, routingResult);

  // Check unidirectional AStar returns same result.
  {
    RoutingResult<Segment, RouteWeight> unidirectionalRoutingResult;
    auto const unidirectionalResultCode = algorithm.FindPath(params, unidirectionalRoutingResult);
    CHECK_EQUAL(resultCode, unidirectionalResultCode, ());
    CHECK(routingResult.m_distance.IsAlmostEqualForTests(unidirectionalRoutingResult.m_distance,
                                                         kEpsilon),
          ("Distances differ:", routingResult.m_distance, unidirectionalRoutingResult.m_distance));
  }

  if (resultCode == AlgorithmForWorldGraph::Result::NoPath)
    return false;

  CHECK_EQUAL(resultCode, AlgorithmForWorldGraph::Result::OK, ());
  CHECK_GREATER_OR_EQUAL(routingResult.m_path.size(), 2, ());
  CHECK_EQUAL(routingResult.m_path.front(), startSegment, ());
  CHECK_EQUAL(routingResult.m_path.back(), finishSegment, ());

  pathEdges.reserve(routingResult.m_path.size());
  pathWeight = 0.0;
  for (auto const & s : routingResult.m_path)
  {
    auto const it = builder.m_segmentToEdge.find(s);
    CHECK(it != builder.m_segmentToEdge.cend(), ());
    auto const & edge = it->second;
    pathEdges.push_back(edge);
    pathWeight += builder.m_segmentWeights[s];
  }

  // The loops from start to start and from finish to finish.
  CHECK_GREATER_OR_EQUAL(pathEdges.size(), 2, ());
  CHECK_EQUAL(pathEdges.front().first, pathEdges.front().second, ());
  CHECK_EQUAL(pathEdges.back().first, pathEdges.back().second, ());
  pathEdges.erase(pathEdges.begin());
  pathEdges.pop_back();

  return true;
}

void TestIndexGraphTopology::AddDirectedEdge(vector<EdgeRequest> & edgeRequests, Vertex from,
                                             Vertex to, double weight) const
{
  uint32_t const id = static_cast<uint32_t>(edgeRequests.size());
  edgeRequests.emplace_back(id, from, to, weight);
}

// TestIndexGraphTopology::Builder -----------------------------------------------------------------
unique_ptr<SingleVehicleWorldGraph> TestIndexGraphTopology::Builder::PrepareIndexGraph()
{
  auto loader = make_unique<ZeroGeometryLoader>();
  auto estimator = make_shared<WeightedEdgeEstimator>(m_segmentWeights);

  BuildJoints();

  auto worldGraph = BuildWorldGraph(move(loader), estimator, m_joints);
  auto & indexGraph = worldGraph->GetIndexGraphForTests(kTestNumMwmId);
  if (m_currentTimeGetter)
    indexGraph.SetCurrentTimeGetter(m_currentTimeGetter);
  indexGraph.SetRoadAccess(move(m_roadAccess));
  return worldGraph;
}

void TestIndexGraphTopology::Builder::BuildJoints()
{
  m_joints.resize(m_numVertices);
  for (uint32_t i = 0; i < m_joints.size(); ++i)
  {
    auto & joint = m_joints[i];

    for (auto const & segment : m_outgoingSegments[i])
      joint.AddPoint(RoadPoint(segment.GetFeatureId(), segment.GetPointId(false /* front */)));

    for (auto const & segment : m_ingoingSegments[i])
      joint.AddPoint(RoadPoint(segment.GetFeatureId(), segment.GetPointId(true /* front */)));
  }
}

void TestIndexGraphTopology::Builder::BuildGraphFromRequests(vector<EdgeRequest> const & requests)
{
  RoadAccess::WayToAccess wayToAccess;
  RoadAccess::WayToAccessConditional wayToAccessConditional;
  RoadAccess::PointToAccess pointToAccess;
  RoadAccess::PointToAccessConditional pointToAccessConditional;
  for (auto const & request : requests)
  {
    BuildSegmentFromEdge(request);
    if (request.m_accessType != RoadAccess::Type::Yes)
      wayToAccess[request.m_id] = request.m_accessType;

    if (!request.m_accessConditionalType.IsEmpty())
      wayToAccessConditional[request.m_id] = request.m_accessConditionalType;

    // All features have 1 segment. |from| has point index 0, |to| has point index 1.
    if (request.m_fromAccessType != RoadAccess::Type::Yes)
      pointToAccess[RoadPoint(request.m_id, 0 /* pointId */)] = request.m_fromAccessType;

    if (!request.m_fromAccessConditionalType.IsEmpty())
    {
      pointToAccessConditional[RoadPoint(request.m_id, 0 /* pointId */)] =
          request.m_fromAccessConditionalType;
    }

    if (request.m_toAccessType != RoadAccess::Type::Yes)
      pointToAccess[RoadPoint(request.m_id, 1 /* pointId */)] = request.m_toAccessType;

    if (!request.m_toAccessConditionalType.IsEmpty())
    {
      pointToAccessConditional[RoadPoint(request.m_id, 1 /* pointId */)] =
          request.m_toAccessConditionalType;
    }
  }

  m_roadAccess.SetAccess(move(wayToAccess), move(pointToAccess));
  m_roadAccess.SetAccessConditional(move(wayToAccessConditional), move(pointToAccessConditional));
  if (m_currentTimeGetter)
    m_roadAccess.SetCurrentTimeGetter(m_currentTimeGetter);
}

void TestIndexGraphTopology::Builder::BuildSegmentFromEdge(EdgeRequest const & request)
{
  auto const edge = make_pair(request.m_from, request.m_to);
  auto p = m_edgeWeights.emplace(edge, request.m_weight);
  CHECK(p.second, ("Multi-edges are not allowed"));

  uint32_t const featureId = request.m_id;
  Segment const segment(kTestNumMwmId, featureId, 0 /* segmentIdx */, true /* forward */);

  m_segmentWeights[segment] = request.m_weight;
  m_segmentToEdge[segment] = edge;
  m_outgoingSegments[request.m_from].push_back(segment);
  m_ingoingSegments[request.m_to].push_back(segment);
}

// Functions ---------------------------------------------------------------------------------------
unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(unique_ptr<TestGeometryLoader> geometryLoader,
                                                    shared_ptr<EdgeEstimator> estimator,
                                                    vector<Joint> const & joints)
{
  auto graph = make_unique<IndexGraph>(make_shared<Geometry>(move(geometryLoader)), estimator);
  graph->Import(joints);
  auto indexLoader = make_unique<TestIndexGraphLoader>();
  indexLoader->AddGraph(kTestNumMwmId, move(graph));
  return make_unique<SingleVehicleWorldGraph>(nullptr /* crossMwmGraph */, move(indexLoader),
                                                   estimator);
}

unique_ptr<IndexGraph> BuildIndexGraph(unique_ptr<TestGeometryLoader> geometryLoader,
                                       shared_ptr<EdgeEstimator> estimator,
                                       vector<Joint> const & joints)
{
  auto graph = make_unique<IndexGraph>(make_shared<Geometry>(move(geometryLoader)), estimator);
  graph->Import(joints);
  return graph;
}

unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(unique_ptr<ZeroGeometryLoader> geometryLoader,
                                                    shared_ptr<EdgeEstimator> estimator,
                                                    vector<Joint> const & joints)
{
  auto graph = make_unique<IndexGraph>(make_shared<Geometry>(move(geometryLoader)), estimator);

  graph->Import(joints);
  auto indexLoader = make_unique<TestIndexGraphLoader>();
  indexLoader->AddGraph(kTestNumMwmId, move(graph));
  return make_unique<SingleVehicleWorldGraph>(nullptr /* crossMwmGraph */, move(indexLoader),
                                              estimator);
}

unique_ptr<TransitWorldGraph> BuildWorldGraph(unique_ptr<TestGeometryLoader> geometryLoader,
                                              shared_ptr<EdgeEstimator> estimator,
                                              vector<Joint> const & joints,
                                              routing::transit::GraphData const & transitData)
{
  auto indexGraph = make_unique<IndexGraph>(make_shared<Geometry>(move(geometryLoader)), estimator);
  indexGraph->Import(joints);

  auto transitGraph = make_unique<TransitGraph>(kTestNumMwmId, estimator);
  TransitGraph::GateEndings gateEndings;
  MakeGateEndings(transitData.GetGates(), kTestNumMwmId, *indexGraph, gateEndings);
  transitGraph->Fill(transitData, gateEndings);

  auto indexLoader = make_unique<TestIndexGraphLoader>();
  indexLoader->AddGraph(kTestNumMwmId, move(indexGraph));

  auto transitLoader = make_unique<TestTransitGraphLoader>();
  transitLoader->AddGraph(kTestNumMwmId, move(transitGraph));

  return make_unique<TransitWorldGraph>(nullptr /* crossMwmGraph */, move(indexLoader),
                                        move(transitLoader), estimator);
}

AlgorithmForWorldGraph::Result CalculateRoute(IndexGraphStarter & starter, vector<Segment> & roadPoints,
                                              double & timeSec)
{
  AlgorithmForWorldGraph algorithm;
  RoutingResult<Segment, RouteWeight> routingResult;

  AlgorithmForWorldGraph::ParamsForTests<AStarLengthChecker> params(
      starter, starter.GetStartSegment(), starter.GetFinishSegment(), nullptr /* prevRoute */,
      AStarLengthChecker(starter));

  auto const resultCode = algorithm.FindPathBidirectional(params, routingResult);

  timeSec = routingResult.m_distance.GetWeight();
  roadPoints = routingResult.m_path;
  return resultCode;
}

void TestRouteGeometry(IndexGraphStarter & starter,
                       AlgorithmForWorldGraph::Result expectedRouteResult,
                       vector<m2::PointD> const & expectedRouteGeom)
{
  vector<Segment> routeSegs;
  double timeSec = 0.0;
  auto const resultCode = CalculateRoute(starter, routeSegs, timeSec);

  TEST_EQUAL(resultCode, expectedRouteResult, ());

  if (AlgorithmForWorldGraph::Result::NoPath == expectedRouteResult &&
      expectedRouteGeom.empty())
  {
    // The route goes through a restriction. So there's no choice for building route
    // except for going through restriction. So no path.
    return;
  }

  if (resultCode != AlgorithmForWorldGraph::Result::OK)
    return;

  CHECK(!routeSegs.empty(), ());
  vector<m2::PointD> geom;

  auto const pushPoint = [&geom](ms::LatLon const & ll) {
    auto const point = mercator::FromLatLon(ll);
    if (geom.empty() || geom.back() != point)
      geom.push_back(point);
  };

  for (auto const & routeSeg : routeSegs)
  {
    auto const & ll = starter.GetPoint(routeSeg, false /* front */);
    // Note. In case of A* router all internal points of route are duplicated.
    // So it's necessary to exclude the duplicates.
    pushPoint(ll);
  }

  pushPoint(starter.GetPoint(routeSegs.back(), false /* front */));
  TEST_EQUAL(geom.size(), expectedRouteGeom.size(), ("geom:", geom, "expectedRouteGeom:", expectedRouteGeom));
  for (size_t i = 0; i < geom.size(); ++i)
  {
    static double constexpr kEps = 1e-8;
    if (!base::AlmostEqualAbs(geom[i], expectedRouteGeom[i], kEps))
    {
      for (size_t j = 0; j < geom.size(); ++j)
        LOG(LINFO, (j, "=>", geom[j], "vs", expectedRouteGeom[j]));

      TEST(false, ("Point with number:", i, "doesn't equal to expected."));
    }
  }
}

void TestRestrictions(vector<m2::PointD> const & expectedRouteGeom,
                      AlgorithmForWorldGraph::Result expectedRouteResult,
                      FakeEnding const & start, FakeEnding const & finish,
                      RestrictionVec && restrictions,
                      RestrictionTest & restrictionTest)
{
  restrictionTest.SetRestrictions(move(restrictions));
  restrictionTest.SetStarter(start, finish);

  TestRouteGeometry(*restrictionTest.m_starter, expectedRouteResult, expectedRouteGeom);
}

void TestRestrictions(vector<m2::PointD> const & expectedRouteGeom,
                      AlgorithmForWorldGraph::Result expectedRouteResult,
                      FakeEnding const & start, FakeEnding const & finish,
                      RestrictionVec && restrictions,
                      vector<RestrictionUTurn> && restrictionsNoUTurn,
                      RestrictionTest & restrictionTest)
{
  restrictionTest.SetRestrictions(move(restrictions));
  restrictionTest.SetUTurnRestrictions(move(restrictionsNoUTurn));

  restrictionTest.SetStarter(start, finish);
  TestRouteGeometry(*restrictionTest.m_starter, expectedRouteResult, expectedRouteGeom);
}

void TestRestrictions(double expectedLength,
                      FakeEnding const & start, FakeEnding const & finish,
                      RestrictionVec && restrictions, RestrictionTest & restrictionTest)
{
  restrictionTest.SetRestrictions(move(restrictions));
  restrictionTest.SetStarter(start, finish);

  auto & starter = *restrictionTest.m_starter;

  double timeSec = 0.0;
  vector<Segment> segments;
  auto const resultCode = CalculateRoute(starter, segments, timeSec);
  TEST_EQUAL(resultCode, AlgorithmForWorldGraph::Result::OK, ());

  double length = 0.0;
  for (auto const & segment : segments)
  {
    auto const back = mercator::FromLatLon(starter.GetPoint(segment, false /* front */));
    auto const front = mercator::FromLatLon(starter.GetPoint(segment, true /* front */));

    length += back.Length(front);
  }

  static auto constexpr kEps = 1e-3;
  TEST(base::AlmostEqualAbs(expectedLength, length, kEps),
       ("Length expected:", expectedLength, "has:", length));
}

void TestTopologyGraph(TestIndexGraphTopology const & graph, TestIndexGraphTopology::Vertex from,
                       TestIndexGraphTopology::Vertex to, bool expectedPathFound,
                       double const expectedWeight,
                       vector<TestIndexGraphTopology::Edge> const & expectedEdges)
{
  double pathWeight = 0.0;
  vector<TestIndexGraphTopology::Edge> pathEdges;
  bool const pathFound = graph.FindPath(from, to, pathWeight, pathEdges);
  TEST_EQUAL(pathFound, expectedPathFound, ());
  if (!pathFound)
    return;

  TEST(base::AlmostEqualAbs(pathWeight, expectedWeight, kEpsilon),
       (pathWeight, expectedWeight, pathEdges));
  TEST_EQUAL(pathEdges, expectedEdges, ());
}

FakeEnding MakeFakeEnding(uint32_t featureId, uint32_t segmentIdx, m2::PointD const & point,
                          WorldGraph & graph)
{
  return MakeFakeEnding({Segment(kTestNumMwmId, featureId, segmentIdx, true /* forward */)}, point,
                        graph);
}
unique_ptr<IndexGraphStarter> MakeStarter(FakeEnding const & start, FakeEnding const & finish,
                                          WorldGraph & graph)
{
  return make_unique<IndexGraphStarter>(start, finish, 0 /* fakeNumerationStart */,
                                        false /* strictForward */, graph);
}

time_t GetUnixtimeByDate(uint16_t year, Month month, uint8_t monthDay, uint8_t hours,
                         uint8_t minutes)
{
  std::tm t{};
  t.tm_year = year - 1900;
  t.tm_mon = static_cast<int>(month) - 1;
  t.tm_mday = monthDay;
  t.tm_hour = hours;
  t.tm_min = minutes;

  time_t moment = mktime(&t);
  return moment;
}

time_t GetUnixtimeByDate(uint16_t year, Month month, Weekday weekday, uint8_t hours,
                         uint8_t minutes)
{
  int monthDay = 1;
  auto createUnixtime = [&]() {
    std::tm t{};
    t.tm_year = year - 1900;
    t.tm_mon = static_cast<int>(month) - 1;
    t.tm_mday = monthDay;
    t.tm_wday = static_cast<int>(weekday) - 1;
    t.tm_hour = hours;
    t.tm_min = minutes;

    return mktime(&t);
  };

  int wday = -1;
  for (;;)
  {
    auto unixtime = createUnixtime();
    auto timeOut = localtime(&unixtime);
    wday = timeOut->tm_wday;
    if (wday == static_cast<int>(weekday) - 1)
      break;
    ++monthDay;
  }

  return createUnixtime();
}
}  // namespace routing_test


text:
import pytest

from procfile import (
    loads,
    loadfile,
)

def test_valid_procfile():
    lines = loads('\n'.join([
        'web: bundle exec rails server -p $PORT',
        'worker: env QUEUE=* bundle exec rake resque:work',
        'urgentworker: env QUEUE=urgent FOO=meh bundle exec rake resque:work',
    ]))
    assert lines == {
        'web': {
            'cmd': 'bundle exec rails server -p $PORT',
            'env': {},
        },
        'worker': {
            'cmd': 'bundle exec rake resque:work',
            'env': {
                'QUEUE': '*',
            },
        },
        'urgentworker': {
            'cmd': 'bundle exec rake resque:work',
            'env': {
                'QUEUE': 'urgent',
                'FOO': 'meh',
            },
        },
    }

def test_duplicate_process_types():
    with pytest.raises(ValueError) as error:
        print(loads('\n'.join([
            'web: bundle exec rails server -p $PORT',
            'web: bundle exec rake resque:work',
        ])))
    assert error.value.args[0] == [
        'Line 2: duplicate process type "web": already appears on line 1.',
    ]

def test_duplicate_variable():
    with pytest.raises(ValueError) as error:
        print(loads('\n'.join([
            'web: bundle exec rails server -p $PORT',
            'worker: env QUEUE=* QUEUE=urgent bundle exec rake resque:work',
        ])))
    assert error.value.args[0] == [
        'Line 2: duplicate variable "QUEUE" for process type "worker".',
    ]

redpajama_set_name: RedPajamaGithub


text:
/*
 * This file is subject to the terms and conditions defined in
 * file 'LICENSE', which is part of this source code package.
 *
 * Partialy financiated as part of the protocol between UTAustin I Portugal - UTA-P.
 * [2017] - [2018] University of Minho, Filipe Costa Oliveira
 * All Rights Reserved.
 */

#include "emd_object.h"

using namespace H5;
using namespace std;

void EMDObject::do_dtype(hid_t tid ){
  t_class = H5Tget_class(tid);
  t_size = H5Tget_size(tid);

  //Returns the native datatype of a specified datatype.

  if(t_class < 0){
    //puts(" Invalid datatype.\n");
  } else {
    /*
     * Each class has specific properties that can be
     * retrieved, e.g., size, byte order, exponent, etc.
     */
    native_dtype = H5Tget_native_type(tid, H5T_DIR_DESCEND );

    if( t_class == H5T_INTEGER ) {
      int_sign = H5Tget_sign(tid);
      /* display size, signed, endianess, etc. */
    } else if(t_class == H5T_FLOAT) {
      /* display size, endianess, exponennt, etc. */
    } else if(t_class == H5T_STRING) {
      /* display size, padding, termination, etc. */
    } else if(t_class == H5T_BITFIELD) {
      //puts(" Datatype is 'H5T_BITFIELD'.\n");
      /* display size, label, etc. */
    } else if(t_class == H5T_OPAQUE) {
      /* display size, etc. */
    } else if(t_class == H5T_COMPOUND) {
      /* recursively display each member: field name, type  */
    } else if(t_class == H5T_ARRAY) {
      /* display  dimensions, base type  */
    } else if(t_class == H5T_ENUM) {
      /* display elements: name, value   */
    } else  {
      /* eg. Object Reference, ...and so on ... */
    }
  }
}

bool EMDObject::is_numeric(){
   bool result = false;
  if( ( t_class == H5T_INTEGER ) || (t_class == H5T_FLOAT) ) {
      result = true;
    }
  return result;
}

bool EMDObject::is_signed_int(){
  bool result = false;
  if( t_class == H5T_INTEGER ) {
      result = ( int_sign == H5T_SGN_2 ) ? true : false;
    }
  return result;
}

void EMDObject::do_link(hid_t gid, char *name){
  herr_t status;
  char target[MAX_NAME];
  status = H5Gget_linkval(gid, name, MAX_NAME, target  ) ;
}


text:
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2006 Warren Chou
 Copyright (C) 2007, 2008 StatPro Italia srl

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@lists.sf.net>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/instruments/varianceswap.hpp>
#include <ql/event.hpp>

namespace QuantLib {

    VarianceSwap::VarianceSwap(
                          Position::Type position,
                          Real strike,
                          Real notional,
                          const Date& startDate,
                          const Date& maturityDate)
    : position_(position), strike_(strike), notional_(notional),
      startDate_(startDate), maturityDate_(maturityDate) {}

    Real VarianceSwap::variance() const {
        calculate();
        QL_REQUIRE(variance_ != Null<Real>(), "result not available");
        return variance_;
    }

    void VarianceSwap::setupExpired() const {
        Instrument::setupExpired();
        variance_ = Null<Real>();
    }

    void VarianceSwap::setupArguments(PricingEngine::arguments* args) const {
        VarianceSwap::arguments* arguments =
            dynamic_cast<VarianceSwap::arguments*>(args);
        QL_REQUIRE(arguments != 0, "wrong argument type");

        arguments->position = position_;
        arguments->strike = strike_;
        arguments->notional = notional_;
        arguments->startDate = startDate_;
        arguments->maturityDate = maturityDate_;
    }

    void VarianceSwap::fetchResults(const PricingEngine::results* r) const {
        Instrument::fetchResults(r);
        const VarianceSwap::results* results =
            dynamic_cast<const VarianceSwap::results*>(r);
        variance_ = results->variance;
    }

    void VarianceSwap::arguments::validate() const {
        QL_REQUIRE(strike != Null<Real>(), "no strike given");
        QL_REQUIRE(strike > 0.0, "negative or null strike given");
        QL_REQUIRE(notional != Null<Real>(), "no notional given");
        QL_REQUIRE(notional > 0.0, "negative or null notional given");
        QL_REQUIRE(startDate != Date(), "null start date given");
        QL_REQUIRE(maturityDate != Date(), "null maturity date given");
    }

    bool VarianceSwap::isExpired() const {
        return detail::simple_event(maturityDate_).hasOccurred();
    }

}


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Mermaid Quick Test Page</title>
  <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">

    graph TB
      Function-->URL
      click Function clickByFlow "Add a div"
      click URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"

  graph TB
    1Function-->2URL
    click 1Function clickByFlow "Add a div"
    click 2URL "http://localhost:9000/webpackUsage.html" "Visit mermaid docs"

    gantt
    dateFormat  YYYY-MM-DD
    axisFormat  %d/%m
    title Adding GANTT diagram to mermaid
    excludes weekdays 2014-01-10

    section A section
    Completed task            :done,    des1, 2014-01-06,2014-01-08
    Active task               :active,  des2, 2014-01-09, 3d
    Future task               :         des3, after des2, 5d
    Future task2               :         des4, after des3, 5d

    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :1d

    section Documentation
    Describe gantt syntax               :active, a1, after des1, 3d
    Add gantt diagram to demo page      :after a1  , 20h
    Add another diagram to demo page    :doc1, after a1  , 48h

    section Clickable
    Visit mermaidjs               :active, cl1, 2014-01-07,2014-01-10
    Calling a Callback (look at the console log) :cl2, after cl1, 3d

    click cl1 href "http://localhost:9000/webpackUsage.html"
    click cl2 call clickByGantt("test", test, test)

    section Last section
    Describe gantt syntax               :after doc1, 3d
    Add gantt diagram to demo page      : 20h
    Add another diagram to demo page    : 48h


text:
<!DOCTYPE html>

    <meta charset="utf-8"/>

    <meta name="viewport" content="width=device-width"/>

    <title>Welcome to BabyCenter | Ad Specifications</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/app.css">
    <link rel="stylesheet" href="css/bc-solutions.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/ad-specs.css">

AD SPECS

RESEARCH & INSIGHTS

MARKETING SOLUTIONS

PRESS

ADVERTISE WITH US

Ad Specifications & Guidelines

            <form class="custom">
                Select Market:
                <select name="markets" id="markets_select" onchange="setSpecs(this);">
                    <option selected>US</option>
                    <option>Other Markets</option>
                </select>
            </form>

                Download in Excel Format

                    Ad Specifications

High Impact Units

Standard IAB Units

Email

Mobile

Video

Integrated Text Units

Ad Effectiveness

High Impact Units

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

Billboard

Size

                            Collapsed: 62w x 88h or 196w x 31h; Expanded: 970w x 250h

Max File Size

                            Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Filmstrip

Size

                            300w x 600h

Max File Size

                            Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; limited to 5 frames

File Types

                            3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Half Page

Size

                            Expanded: 500w x 600h; Collapsed: 300w x 600h

Max File Size

                            Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF/JPG/SWF plus click-through URL; 3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Push Down

Size

                            Expanded: 970w x 418h; Collapsed: 970w x 66h

Max File Size

Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            3rd party tag auto-expand permitted 1/user/day with auto-retract after 7 seconds; expansion must be
                            user-initiated on subsequent impressions

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Wallpaper

Size

                            1280w with 1026w white space centered in the image

Max File Size

80KB

Loop Time

                            N/A

File Types

                            GIF or JPG plus click-through URL;

                            Logo must be smaller than BabyCenter logo and 250 pixels down from the top of the page; logo cannot be on left rail;

                            Creative is subject to BabyCenter approval and must be submitted 10 business days prior to launch

3rd Party Serving

                            No

Back to top

Standard IAB Units

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

Leaderboard

Size

                            728w x 90h

Max File Size

                            Image: 40KB; 3rd party tag: Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF/JPG/SWF plus click-through URL; 3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Skyscraper

Size

                            160w x 600h

Max File Size

                            Image: 40KB; 3rd party tag: Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF/JPG/SWF plus click-through URL; 3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Medium Rectangle

Size

                            300w x 250h

Max File Size

                            Image: 40KB; 3rd party tag: Initial 40KB, Secondary 140KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF/JPG/SWF plus click-through URL; 3rd party tag

3rd Party Serving

                            BabyCenter web sites support the following 3rd party tags:
                            Atlas, DFA*, DoubleClick Studio, Flashtalking, MediaMind, PointRoll, All other vendors must be tested and
                            approved on a case-by-case basis. (DFA internal redirect in .txt file)

                            See Rich Media Guidelines

Logo

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            N/A

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Back to top

Email

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

Stage-Based Newsletter

Size

                            300w x 250h

Max File Size

                            25KB

Loop Time

                            32 characters including spaces

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Bulletin Newsletter

Size

                            300w x 250h

Max File Size

                            25KB

Loop Time

                            75 characters including spaces

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Daily Digest

Size

                            160w x 600h

Max File Size

                            25KB

Loop Time

                            N/A

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Mom Answers

Size

                            300w x 250h

Max File Size

                            25KB

Loop Time

                            N/A

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Partner Standalone Email Option 1: Client-Provided HTML

Size

                            No more than 700w

                            See Email Guidelines

Max File Size

                            250KB

Loop Time

                            Subject Line: 50 characters including spaces

File Types

                            HTML tables only;

                            No external style sheet, Flash, JavaScript, or other non-HTML code

3rd Party Serving

                            No

Partner Standalone Email Option 2: BabyCenter Template

Size

                            300w x 250h for image

Max File Size

                            30KB

Loop Time

                            Subject Line: 50 characters including spaces;

                            Headline: 50 characters including spaces;

                            Body: 150 words (text provided in Word or Notepad)

File Types

                            GIF or JPG plus click-through URL;

                            Up to 3 click-through URLs for linked text in body copy

3rd Party Serving

                            No

Free Stuff Great Deals

Size

                            300w x 250h

Max File Size

                            30KB

Loop Time

                            50 characters including spaces

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                            No

Video Milestone

Size

                            300w x 250h

Max File Size

                            25KB

Loop Time

                            N/A

File Types

                            GIF or JPG plus click-through URL

3rd Party Serving

                                No

Back to top

Mobile

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

Mobile Web 300x50

Size

                            300w x 50h or 320w x 50h

Max File Size

                            Image: 20KB; 3rd party tag: Initial 20KB, Secondary 80KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Mobile Web Adhesion

Size

                            300w x 50h or 320w x 50h

Max File Size

                            Image: 20KB; 3rd party tag: Initial 20KB, Secondary 80KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Mobile Web 300x250

Size

                            300w x 250h or 320w x 250h

Max File Size

                            Image: 20KB; 3rd party tag: Initial 20KB, Secondary 80KB

Loop Time

                            N/A

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Mobile Web Peek-a-Boo

Size

                            300w x 300h or 320w x 480h

Max File Size

                            Image: 30KB; 3rd party tag: Initial 30KB, Secondary 100KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Mobile Web Sideswipe

Size

                            300w x 250h or 320w x 250h

Max File Size

                            Image: 30KB;

                            3rd party tag: Initial 30KB, Secondary 100KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Mobile App 300x50

Size

                            300w x 50h or 320w x 50h

Max File Size

                            Image: 20KB;

                            3rd party tag: Initial 20KB, Secondary 80KB

Loop Time

                            15 seconds total animation; no more than 3 loops

File Types

                            GIF, JPG, 3rd party tag

3rd Party Serving

                            BabyCenter mobile web sites support the following 3rd party
                            tags: Celtra, Crisp, DFA, Medialets, MediaMind, Pointroll, and REVV (Rubicon). All other vendors must be
                            tested and approved on a case-by-case basis.

Back to top

Video

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

Pre-Roll Video

Size

                            480w x 360h

Max File Size

                            5MB

Loop Time

                            15 seconds

File Types

                            Video: MOV file using the H.264 codec at 29.97 fps plus
                            click-through URL;

                            Audio: AAC format in stereo at 44.1 kHz (no higher than 48 kHz); MPEG-4 AAC
                            LC Encoder Setting: "Normal"; Encoding Strategy: "Average Bit Rate"; Target Bit Rate: "195 kbps"

3rd Party Serving

                            BabyCenter videos support the following VAST 2.0 (wrapper and
                            inline) and VPAID 3rd party tags: Innovid, Vindico. All other vendors must be tested and approved on a
                            case-by-case basis.

Companion Ad

Size

                            300w x 250h

Max File Size

                            40KB

Loop Time

                            N/A

File Types

                            GIF/JPG/SWF

3rd Party Serving

                            No

Logo

Size

                            88w x 31h or 468w x 60h

Max File Size

                            30KB

Loop Time

                            N/A

File Types

                            GIF or JPG only

3rd Party Serving

                            No

Partner Video

Size

                            720w minimum

Max File Size

                            2GB

Loop Time

                            Title: 50 characters including spaces (preferred format: "Video title, by Sponsor");

                            Description: 50 characters including spaces

File Types

                            Video: Uncompressed MOV master file or 2000k (Apple proprietary codec such as Apple ProRes not permitted);

                            Audio: AAC format in stereo at 44.1 kHz (no higher than 48 kHz); MPEG-4 AAC LC Encoder Setting: "Normal"; Encoding Strategy: "Average Bit Rate";
                            Target Bit Rate: "195 kbps"

3rd Party Serving

                            No

Back to top

Integrated Text Units

AD TYPE

DIMENSIONS

MAXIMUM FILE SIZE

LOOP TIME

FILE TYPES

3rd PARTY SERVING

BabyCenter Blog

Size

                            88w x 31h or 125w x 125h

Max File Size

                            30KB

Loop Time

                            Headline: 36 characters, including spaces;

                            Body: 144 characters, including spaces;

                            Link: 48 characters, including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Expert Answers

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            Question: 100 characters including spaces;

                            Answer: 150 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Free Stuff & Great Deals

Size

                            300w x 250h

Max File Size

                            40KB

Loop Time

                            60 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Integrated Textlink

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            100 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Milestones

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            100 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Mom Answers

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            60 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

My Family Module

Size

                            88w x 31h

Max File Size

                            30KB

Loop Time

                            60 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Search

Size

                            88w x 31h

Max File Size

                            N/A

Loop Time

                            60 characters including spaces

File Types

                            Text plus GIF/JPG and click-through URL

3rd Party Serving

                            No

Back to top

Ad Effectiveness

                            For campaigns including ad effectiveness recruitment, we can apply one exposed
                            tag per campaign to the following site served creatives:

Bulletin Newsletter Email

Partner Standalone Email

Integrated Text Units (excluding Free Stuff & Great Deals)

Logo

Video Preroll

Back to top

                    Guidelines

Rich Media Guidelines

Flash Guidelines

Flash 7,8,9 or 10 required

Flash 11 Recommended

Flash best practices: here

Maximum File Size

SWF: 40KB

Backup GIF/JPG: 40KB

3rd Party Tag: Initial 40KB, Secondary 140KB

Z-Index: 499

Click Tracking

Do not hardcode URL

Flash clickTag required: getURL(clickTag, "_blank")

One clickTag per SWF

Click-through URL must open a new browser window

Entire area and all frames of SWF must be clickable

Additional clickTag information:http://www.adobe.com/resources/richmedia/tracking/designers_guide/

Audio/Video

Creative must default to no sound. Sound must be activated by user click -- not mouse-over

Video auto-play without sound permitted

Always present, clearly labeled play, pause and mute buttons required

Expanding Rich Media Execution

For expanding rich media, consider Flash guidelines as well as the following:

Maximum file size is 40 KB on initial load, plus up to 140 KB on secondary load after
                                    mouse-over or click

Expansion must be user-initiated by mouse-over or click. Hot spot limited to a maximum of 50% of
                                    the area of the collapsed unit.
                                    We recommend using a call-to-action for the mouse-over or clickable area.

Prominent and clearly labeled "Close" button must be
                                    visible on expanded panels at all times

A panel initiated by mouse-over must retract immediately when the user withdraws the mouse.
                                    A panel initiated by click can retract when the user withdraws the mouse or clicks the "Close"
                                    button.

Expanding rich media must be a 3rd party tag. We do not accept expanding SWFs

Expansion Limits

728x90 can expand to a maximum size of 728x350.

160x600 can expand right to a maximum size of 320x600.

300x250 can expand left, up, or down to a maximum size of 500x250 or 300x500

Z-Index: 499

Video-In Banner

                                For video in-banner placements, follow Flash and expanding rich media guidelines as well as the
                                following:

Maximum file size is 40KB on initial load, plus up to 2.2MB true streaming or progressive
                                    download after mouse-over or click.

Maximum video length is 30 seconds.

Mobile Rich Media

Maximum file size is 20 KB on initial load, plus up to 80 KB on secondary load after tap

Expansion must be user-initiated with a tap. Expanded panel should fill the browser screen
                                    (consult your rich media vendor).
                                    A prominent and clearly labeled "Close" button must be visible on expanded panel at all times.

Maximum in-banner video file size is 1 MB after user taps to play video

Email Guidelines

                                    If you are providing HTML for a standalone email, please keep in mind the
                                    following standards and guidelines.

                                    The client is responsible for testing to ensure that the email creative works as expected across
                                    platforms and email browsers. Those expectations should include customer-defined handling of your email,
                                    such as image blocking, third-party tracking, and whether the email creative will trigger the message
                                    to be considered "spam," either by the customer's ISP or the recipient.

HTML Code

Please provide only the HTML to be included in the body of the message.
                                    We will remove and/or replace the <HTML>, <HEAD>, <TITLE>, <SCRIPT>
                                    and <BODY> tags. Any attributes included in those tags in your file will be stripped out.

Your HTML file needs to be coded using HTML tables and nested tables only.
                                    They are still the standard for email. Table-less layouts (CSS positioning) are not accepted.

We add the BabyCenter header and footer to all Standalone email. Our content includes the
                                    BabyCenter unsubscribe links.
                                    Do not include any copy that references unsubscribing to a mailing list,
                                    personalization or other features that refer to either the advertisers or BabyCenter's customer data.

Your HTML email should be no more than 700 pixels wide. File size maximum of 250K

Cascading Style Sheets (CSS) are not supported by many email clients or are supported with
                                    inconsistent results.
                                    For this reason, we do not support external files, such as CSS style sheets, or <SCRIPT>
                                    blocks in the head of the email. They will be removed.

All URLs for click-through links must be absolute, not relative, and embedded in the code.
                                    BabyCenter will not populate custom click-through URLs.

Font styles are defined inline in the nearest tag <td>, <a> or <span>.
                                    Include the full font attributes in each tag that contains HTML text or the font may default to
                                    the browser settings.
                                    Define font size in pixels, not points.

Do not use Flash, video or any kind of rich media in email. It is not supported by most email
                                    browsers. JavaScript does not work in email. Forms are not supported and are not permitted.

Tags to avoid: Avoid using paragraph tags <p> as they are not recognized in some email
                                    clients. Use 2 break tags <br> instead.
                                    Avoid the use of list tags <ul>, <ol> or <li> as they do not display in some
                                    browsers. Avoid setting margins in the table tag as they do not render consistently across email
                                    clients.

Avoid commenting out HTML code as it may display in some browsers.

Validate your HTML code. Make sure there are no nesting errors as an improper tag
                                    closing will cause rendering errors in many email clients. Most HTML editors include a
                                    validation utility. Otherwise, go to http://validator.w3.org/

Images

Images may either be hosted on your own or provided to BabyCenter along with your
                                    HTML file. Externally-hosted images must have absolute URLs.
                                    Images provided to BabyCenter should be named in lower-case characters
                                    with no spaces, and contained in only one folder, with no nesting.

All image tags should include height, width, alt and border attributes.
                                    Borders should be set to zero i.e. border="0". All graphics must have their
                                    correct dimensions in the file properties. Do not rely on HTML-defined
                                    dimensions or resize images in HTML code.

Background images are not recommended as some email clients will strip them out.
                                    If you chose to use background images, make sure that the email still works if they
                                    do not display. Consider whether font type colors will appear if the background images do not.

Animated GIFs are not permitted.

Image maps are supported but not recommended.

Consider a mix of plain text and images in your email design.
                                    Keep in mind that if images are blocked in a customer's email browser, alt text may
                                    also not appear. Always consider how the message may appear if images do not render
                                    for the user.

Anti-Spam Recommendations

Email Content

Do not capitalize every word. Be extremely selective in using words with all caps.

Avoid excessive use of $ signs and exclamation points.
                                    Do not use multiple symbols one after another. For example, the following are not
                                    recommended: Free!! Now!!! Save$$$$

Include the company's name or abbreviation. This is necessary so readers know which advertiser
                                    the information is coming from

No trademark signs, copyright signs or special symbols. BabyCenter style is to refrain from
                                    using trademark or copyright signs with brand/product names—we just leave it out altogether.
                                    This applies to both special symbols (TM, ©, ®) and plain text (TM, (R), (C)).

Avoid sending emails containing more than 50% HTML tags.

Avoid links without an http:// prefix.

Avoid HTML forms.

Email Subject Lines

Subject lines should generally be no more than 50 characters.

Subject lines should be truthful and relate to the message in the body of the email.

Do not use more than two symbols and do not use the combination ($....!) or multiple symbols in a row.

Do not use all caps.

Do not create excessive white space between words (e.g., Free Shipping on shoes).

                                    BabyCenter Advertising Terms & Conditions

Back to top

                    Sign up for our weekly emails that detail your baby's development

                Get our FREE Apps

                         My Pregnancy
                        Today

                         My
                        Baby
Today

                        Birth Class App for iPad

                         BabyCenter
                        Blog

                         Like us on Facebook

                          Follow us on Pinterest

                        BabyCenter Community

                        Follow us on Twitter

                        Love us?

                Best Family & Parenting Site

                Top Go-To Resource for Expecting Moms

BabyCenter Shortcuts

Getting Pregnant

Pregnancy

Baby

Toddler

Preschoolers

Big Kid

Breastfeeding

Community

Baby Names

Pregnancy Calendar

Pregnancy Symptoms

Pregnancy Calculator

Pregnancy Stages

Pregnancy Week by Week

Text4baby

Get Help

About BabyCenter, L.L.C.

Help Center

Press Center

Contact Us

Site Map

Ovulation Calculator

Baby Care

Baby Development

Baby Nutrition

Baby Shower Games

Baby Shower Ideas

Fetal Development

Free Baby Stuff

Baby Name Meanings

Mother-Baby Horoscopes

Food & Recipes

Birth Announcements

Expert Answers

Mom Answers

Membership & Newsletters

Newsletters

Register

Manage Email Subscriptions

Update Account

Our U.S. Sites

BabyCenter

BabyCenter Community

BabyCenter en Español

Baby.com

Pregnancy.com

BabyCenter Blog

Behind the Scenes

Marketing & Advertising Solutions

Media Kit

Jobs

Shop Diapers.com

Baby
                    Registry

Baby Products

Britax
                    Car Seats

Legal

Privacy Policy

Terms of Use

Our International Sites

Arabia

Australia

Brasil

Canada

China

France

Germany

India

Korea

Latin America

Malaysia

Russia

UK

Select one of the markets you are interested in:

US

UK

Canada

Other Markets

    X


text:
namespace _11.Geometry_Calculator
{
    using System;

    class Program
    {
        static void Main()
        {
            var figure = Console.ReadLine().ToLower();

            switch (figure)
            {
                case "triangle":
                    TriangleArea();
                    break;
                case "square":
                    SquareArea();
                    break;
                case "rectangle":
                    RectangleArea();
                    break;
                case "circle":
                    CircleArea();
                    break;
                default: break;
            }
        }

        private static void TriangleArea()
        {
            var side = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());
            double result = (side * height) / 2;

            Console.WriteLine("{0:f2}", result);
        }

        private static void SquareArea()
        {
            var side = double.Parse(Console.ReadLine());
            double result = Math.Pow(side, 2);

            Console.WriteLine("{0:f2}", result);
        }

        private static void RectangleArea()
        {
            var side = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());
            double result = side * height;

            Console.WriteLine("{0:f2}", result);
        }

        private static void CircleArea()
        {
            var r = double.Parse(Console.ReadLine());
            double result = Math.PI * Math.Pow(r, 2);

            Console.WriteLine("{0:f2}", result);
        }
    }
}


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
Mykol. Unters. Tropen 104 (1898)

#### Original name
Vanromburghia Holterm.

### Remarks
null


text:
<?php
class SiteMap
{
  public $sitemapFileName = "sitemap.xml";
  public $sitemapIndexFileName = "sitemap-index.xml";
  public $robotsFileName = "robots.txt";
  //public $maxURLsPerSitemap = 50000;
  //public $createGZipFile = false;
  private $_baseUrl;
  private $_basePath;
  private $_searchEngines = array(
                                  array("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=USERID&url=",
                                        "http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap="),
                                  "http://www.google.com/webmasters/tools/ping?sitemap=",
                                  "http://submissions.ask.com/ping?sitemap=",
                                  "http://www.bing.com/webmaster/ping.aspx?siteMap="
                                  );
  private $_urls;
  private $_sitemaps;
  private $_sitemapIndex;
  private $_fileSitemap;
  private $_fileSitemapIndex;
  public function SiteMap ($baseUrl, $basePath = '')
  {
    $this->_baseUrl= $baseUrl;
    $this->_basePath = $basePath;
  } //end function __constructor

  public function init ()
  {
    $this->_openFileSitemapIndex();
    $this->_openFileSitemap();
//    echo $this->_fileSitemapIndex  .'-'.$this->sitemapFileName. PHP_EOL;exit;
    fwrite($this->_fileSitemapIndex, "<sitemap><loc>{$this->_baseUrl}/{$this->sitemapFileName}</loc></sitemap>");
  } //end function init
  public function done ()
  {
    $this->_closeFileSitemapIndex();
    $this->_closeFileSitemap();
  } //end function done

  function addUrl ($url, $lastModified = null, $changeFrequency = null, $priority = null)
  {
    fwrite($this->_fileSitemap, "<url>\n"
           . "\t<loc>".htmlspecialchars($url,ENT_QUOTES,'UTF-8')."</loc>\n"
           . (($lastModified)?"\t<lastmod>$lastModified</lastmod>\n":'')
           . (($changeFrequency)?"\t<changefreq>$changeFrequency</changefreq>\n":'')
           . (($priority)?"\t<priority>$priority</priority>":'')
           . "</url>\n");
  } //end function addUrl
  protected function _openFileSitemapIndex ()
  {
    $this->_fileSitemapIndex = fopen($this->_basePath . $this->sitemapIndexFileName,'w');
    $sitemapIndexHeader = '<?xml version="1.0" encoding="UTF-8"?>'."\n"
      . '<sitemapindex '."\n"
      . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n"
      . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . "\n"
      . 'http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"' . "\n"
      . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
    fwrite($this->_fileSitemapIndex, $sitemapIndexHeader);
  } //end function initFileSitemapIndex
  protected function _closeFileSitemapIndex ()
  {
    fwrite($this->_fileSitemapIndex, "\n</sitemapindex>\n");
    fclose($this->_fileSitemapIndex);
  } //end function _closeFileSitemapIndex
  public function addSitemap ($filename)
  {
    if ( $this->_fileSitemap ){
      $this->_closeFileSitemap();
    } //end if $this->_fileSitemap
    fwrite($this->_fileSitemapIndex, "\n<sitemap><loc>{$this->_baseUrl}/$filename</loc></sitemap>");
    $this->sitemapFileName = $filename;
    $this->_openFileSitemap();
    return true;
  } //end function addSitemap

  protected function _openFileSitemap ()
  {
    $sitemapHeader = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
      . '<urlset' ."\n"
      . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n"
      . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . "\n"
      . 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"' . "\n"
      . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

    $this->_fileSitemap = fopen($this->_basePath . $this->sitemapFileName,'w');
    fwrite($this->_fileSitemap, $sitemapHeader);
  } //end function initFileSitemap

  protected function _closeFileSitemap ()
  {
    fwrite($this->_fileSitemap,"\n</urlset>\n");
    fclose($this->_fileSitemap);
  } //end function _closeFileSitemap

  public function send($yahooAppId = null) {
    if (!extension_loaded('curl'))
      throw new BadMethodCallException("cURL library is needed to do submission.");
    $sitemapFullURL = $this->_baseUrl.'/'.$this->sitemapIndexFileName;
    $searchEngines = $this->_searchEngines;
    $searchEngines[0] = isset($yahooAppId) ? str_replace("USERID", $yahooAppId, $searchEngines[0][0]) : $searchEngines[0][1];
    $result = array();
    for($i=0;$i<sizeof($searchEngines);$i++) {
      $submitSite = curl_init($searchEngines[$i].htmlspecialchars($sitemapFullURL,ENT_QUOTES,'UTF-8'));
// curl_setopt($submitSite, CURLOPT_HTTPPROXYTUNNEL, 1);
// curl_setopt($submitSite, CURLOPT_PROXYPORT, 9090);
// curl_setopt($submitSite, CURLOPT_PROXY, 'http://172.19.0.4:9090');
// curl_setopt($submitSite, CURLOPT_PROXYUSERPWD, 'pacmamhe:draco12');
      curl_setopt($submitSite, CURLOPT_RETURNTRANSFER, true);
      $responseContent = curl_exec($submitSite);
      $response = curl_getinfo($submitSite);
      $submitSiteShort = array_reverse(explode(".",parse_url($searchEngines[$i], PHP_URL_HOST)));
      $result[] = array("site" => $submitSiteShort[1].".".$submitSiteShort[0],
                        "fullsite "=> $searchEngines[$i].htmlspecialchars($sitemapFullURL, ENT_QUOTES,'UTF-8'),
                        "http_code" => $response['http_code'],
                        "message" => str_replace("\n", " ", strip_tags($responseContent)));
    }
    return $result;
  }

  public function updateRobots() {
    $sampleRobotsFile = "User-agent: *\nAllow: /";
    $sitemapFullURL = $this->_baseUrl.'/'.$this->sitemapIndexFileName;
    if (file_exists($this->_basePath . $this->robotsFileName)) {
      $robotsFile = explode("\n", file_get_contents($this->_basePath . $this->robotsFileName));
      $robotsFileContent = "";
      foreach($robotsFile as $key=>$value) {
        if(substr($value, 0, 8) == 'Sitemap:') unset($robotsFile[$key]);
        else $robotsFileContent .= $value."\n";
      }
      $robotsFileContent .= "Sitemap: $sitemapFullURL";
      file_put_contents($this->_basePath . $this->robotsFileName,$robotsFileContent);
    }
    else {
      $sampleRobotsFile = $sampleRobotsFile."\n\nSitemap: ".$sitemapFullURL;
      file_put_contents($this->_basePath . $this->robotsFileName, $sampleRobotsFile);
    }
  }
} //end class SiteMap
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..'));
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/vendor/zendframework/zendframework/library'),
    get_include_path()
)));

    require_once 'Zend/Loader/StandardAutoloader.php';
    $config =include APPLICATION_PATH .'/config/autoload/global.php';
    $autoLoader = new Zend\Loader\StandardAutoloader(array(
                'prefixes' => array(
                'MyVendor' => '/vendor/zendframework/zendframework/library/Zend',
                ),
                'fallback_autoloader' => true,
                ));

                // register our StandardAutoloader with the SPL autoloader
                $autoLoader->register();
    $adapter=new \Zend\Db\Adapter\Adapter($config['db']);
    $baseUrl=$config['host']['base'];
    $avisoSitemapCount = 1;
$sm = new SiteMap($baseUrl, APPLICATION_PATH .'/public/');
$sm->sitemapIndexFileName = 'sitemap_index.xml';
$sm->sitemapFileName = 'platos'.str_pad($avisoSitemapCount,2,'0',STR_PAD_LEFT).'_sitemap.xml';
$sm->init();

    $platos=$adapter->query('SELECT ta_plato.in_id,ta_plato.va_nombre,tr.va_nombre AS restaurante
                FROM ta_plato
                LEFT JOIN `ta_plato_has_ta_local` AS `pl` ON `pl`.`ta_plato_in_id` = `ta_plato`.`in_id`
                LEFT JOIN `ta_local` AS `tl` ON `tl`.`in_id` = `pl`.`ta_local_in_id`
                LEFT JOIN `ta_restaurante` AS `tr` ON `tr`.`in_id` = `tl`.`ta_restaurante_in_id`
                WHERE   ta_plato.en_estado=1  AND tr.en_estado=1
                GROUP BY in_id',$adapter::QUERY_MODE_EXECUTE);
    include APPLICATION_PATH.'/module/Application/src/Application/View/Helper/CanonicalUrl.php';
    include APPLICATION_PATH.'/module/Application/src/Application/View/Helper/Canonical.php';
    $crul=new Application\View\Helper\CanonicalUrl();
    $limpiando=new Application\View\Helper\Canonical();
      foreach($platos as $plato){
          $platourl=$crul($limpiando($plato->va_nombre), array('suffix' =>$plato->in_id));
          $restauranteurl=$crul($limpiando($plato->restaurante));
          $sm->addUrl($baseUrl . '/plato/'.$restauranteurl.'/' . $platourl);
        }
$sm->updateRobots();
$result = $sm->send();
print_r($result);
$sm->done();

echo "\nUso de memoria: " . number_format(memory_get_peak_usage()/(1024*1024),2)."MB\n";
$time2 = explode(" ",microtime());
$time2 = $time2[1];
echo "\nTiempo de ejecución: " . number_format($time2-$time)."s\n";

die();


text:
#ifndef REFINE_DIM
#define REFINE_DIM 2
#endif

#ifndef PATCH_DIM
#define PATCH_DIM 2
#endif

#if 0
/* Fix syntax highlighting */
#endif

#if PATCH_DIM == 2

#define METRIC_VTABLE_NAME "fclaw2d_metric"

#include "fclaw2d_metric.h"
#include "fclaw2d_metric.hpp"

#elif PATCH_DIM == 3 && REFINE_DIM == 2

#define METRIC_VTABLE_NAME "fclaw3d_metric"

#include "fclaw3d_metric.h"
#include "fclaw3d_metric.hpp"

#include <_fclaw2d_to_fclaw3d.h>

#else
#error "Octree refinement not yet implemented"
#endif

#include <fclaw_pointer_map.h>

#include <fclaw2d_global.h>
#include <fclaw2d_patch.h>

static
fclaw2d_metric_patch_t* get_metric_patch(fclaw2d_global_t* glob,
                                         fclaw2d_patch_t *patch)
{
    return (fclaw2d_metric_patch_t*) fclaw2d_patch_metric_patch(glob, patch);
}

/* ----------------------------- Creating/deleting patches ---------------------------- */

fclaw2d_metric_patch_t* fclaw2d_metric_patch_new()
{
    fclaw2d_metric_patch_t *mp = new fclaw2d_metric_patch_t;
    return mp;
}

void fclaw2d_metric_patch_delete(fclaw2d_metric_patch_t **mp)
{
    FCLAW_ASSERT(mp != NULL);
    delete *mp;
    *mp = NULL;
}

#if PATCH_DIM == 2
void fclaw2d_metric_patch_define(fclaw2d_global_t* glob,
                                 fclaw2d_patch_t* patch,
                                 int mx, int my, int mbc,
                                 double dx, double dy,
                                 double xlower, double ylower,
                                 double xupper, double yupper,
                                 int blockno, int patchno,
                                 fclaw2d_build_mode_t build_mode)
#elif PATCH_DIM == 3
void fclaw3d_metric_patch_define(fclaw2d_global_t* glob,
                                 fclaw2d_patch_t* patch,
                                 int mx, int my, int mz, int mbc,
                                 double dx, double dy,double dz,
                                 double xlower, double ylower, double zlower,
                                 double xupper, double yupper, double zupper,
                                 int blockno, int patchno,
                                 fclaw2d_build_mode_t build_mode)
#endif

{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);

    mp->mx   = mx;
    mp->my   = my;
    mp->mbc  = mbc;
    mp->blockno = blockno;

    mp->dx = dx;
    mp->dy = dy;
    mp->xlower = xlower;
    mp->ylower = ylower;
    mp->xupper = xupper;
    mp->yupper = yupper;

#if PATCH_DIM == 3
    mp->mz = mz;
    mp->zlower = zlower;
    mp->zupper = zupper;
    mp->dz = (mp->zupper - mp->zlower)/mp->mz;
#endif

    /* Set up area for storage - this is needed for ghost patches,
    and updated patches */
    Box box_p, box_d;
    {
        /* Create box for primary grid (cell-centered) */
        int ll_p[PATCH_DIM];
        int ur_p[PATCH_DIM];
        for (int idir = 0; idir < PATCH_DIM; idir++)
        {
            ll_p[idir] = -mbc;
        }
        ur_p[0] = mp->mx + mbc + 1;
        ur_p[1] = mp->my + mbc + 1;
#if PATCH_DIM == 3
        ur_p[2] = mp->mz + mbc + 1;
#endif

        box_p = Box(ll_p,ur_p,PATCH_DIM);

        /* Create box for nodes (cell corners) */
        int ll_d[PATCH_DIM];
        int ur_d[PATCH_DIM];

        /* Create node centered box */
        for (int idir = 0; idir < PATCH_DIM; idir++)
        {
            ll_d[idir] = -mbc;
        }
        ur_d[0] = mp->mx + mbc + 2;
        ur_d[1] = mp->my + mbc + 2;

#if PATCH_DIM == 3
        ur_d[2] = mp->mz + mbc + 2;
#endif

        box_d = Box(ll_d,ur_d,PATCH_DIM);

#if PATCH_DIM == 2
        mp->area.define(box_p,1);
#elif PATCH_DIM == 3
        /* volume is needed in ghost patches for averaging.   The face area is
           only needed if we are updating a cell, but since volume and
           face area are computed together, we should also allocate memory
           for face areas
        */
        mp->volume.define(box_p,1);
        mp->face_area.define(box_d,3);

        /* Node values are needed by parallel ghost patches when we have an
           affine map.  In this case, the affine map can use pre-computed xd,yd,zd
           values.

           Note: This should be revisited since we are doing extra work for the affine
           map.
        */
        mp->xd.define(box_d,1);
        mp->yd.define(box_d,1);
        mp->zd.define(box_d,1);
#endif

    }

    /* Only allocate memory that is needed */
    if (build_mode != FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED
       && build_mode == FCLAW2D_BUILD_FOR_UPDATE)
    {
        /*
        From here on out, we build for patches that get updated

        In 2d manifold :
        24 additional field variables needed for all metric terms on a
        manifold
            xp,yp,zp           : 3
            xd,yd,zd           : 3
            surf_normals       : 3    (3x1 vector)
            curvature          : 1
            area               : 1
            <xy>face normals   : 6    (2 3x1 vectors)
            <xy>face tangents  : 6    (2 3x1 vectors)
            edge lengths       : 2
            -----------------------
            Total              : 25

        In 3d :
        36 additional field variables needed for all metric terms
            xp,yp,zp           : 3
            xd,yd,zd           : 3
            face areas         : 3
            volume             : 1
            rotation matrix    : 27 (3 3x3 matrices)
            -----------------------
            Total              : 37

            We should come up with a way to store only what is needed
        */

        /* Mesh cell centers of physical mesh */
        mp->xp.define(box_p,1);
        mp->yp.define(box_p,1);
        mp->zp.define(box_p,1);

#if PATCH_DIM == 2

        mp->xd.define(box_d,1);
        mp->yd.define(box_d,1);
        mp->zd.define(box_d,1);

        mp->surf_normals.define(box_p,3);
        mp->curvature.define(box_p,1);

        /* Store length of left and bottom edge of box */
        /* Face centered values */
        /* DAC : Why didn't I set this up as a cell-centered box? */
        mp->xface_normals.define(box_d,3);
        mp->yface_normals.define(box_d,3);
        mp->xface_tangents.define(box_d,3);
        mp->yface_tangents.define(box_d,3);

        mp->edge_lengths.define(box_d,2);
#elif PATCH_DIM == 3
        /* Store face areas of left, front, bottom edge of box */
        //mp->face_area.define(box_d,3);

        /* Store 3x3 rotation matrix for each of three faces */
        mp->xrot.define(box_d,9);
        mp->yrot.define(box_d,9);
        mp->zrot.define(box_d,9);
#endif

    }
}

/* For 3d extruded mesh, this averages cell volumes */
static
void metric_average_area_from_fine(fclaw2d_global_t *glob,
                                   fclaw2d_patch_t *fine_patches,
                                   fclaw2d_patch_t *coarse_patch,
                                   int blockno,
                                   int coarse_patchno,
                                   int fine0_patchno)
{
    fclaw2d_metric_vtable_t *metric_vt = fclaw2d_metric_vt(glob);
    int mx,my, mbc;
    double xlower,ylower,dx,dy;

#if PATCH_DIM == 2
    fclaw2d_metric_patch_grid_data(glob,coarse_patch,&mx,&my,&mbc,
                                   &xlower,&ylower,&dx,&dy);
    double *areacoarse = fclaw2d_metric_patch_get_area(glob, coarse_patch);
#elif PATCH_DIM == 3
    int mz;
    double zlower, dz;
    fclaw3d_metric_patch_grid_data(glob,coarse_patch,&mx,&my,&mz,&mbc,
                                   &xlower,&ylower,&zlower,&dx,&dy,&dz);
    double *volcoarse, *fa_coarse;
    fclaw3d_metric_patch_scalar(glob,coarse_patch,&volcoarse, &fa_coarse);
#endif

    for(int igrid = 0; igrid < 4; igrid++)
    {

#if PATCH_DIM == 2
        double* areafine = fclaw2d_metric_patch_get_area(glob,
                                                         &fine_patches[igrid]);
        FCLAW2D_METRIC_FORT_AVERAGE_AREA(&mx,&my,&mbc,
                                         areacoarse,
                                         areafine,&igrid);
#elif PATCH_DIM == 3
#if REFINE_DIM == 2
        double *volfine, *fa_fine;
        fclaw3d_metric_patch_scalar(glob,&fine_patches[igrid],&volfine, &fa_fine);

        /* Average from fine to coarse when creating coarse grid from a fine grid.
           This will be exact, since both volume and face areas are computing at
           finest level resolution.
        */
        FCLAW3DX_METRIC_FORT_AVERAGE_VOLUME(&mx,&my,&mz, &mbc,
                                            volcoarse,volfine,
                                            &igrid);

        FCLAW3DX_METRIC_FORT_AVERAGE_FACEAREA(&mx,&my,&mz, &mbc,
                                              fa_coarse,fa_fine, &igrid);
#else
        fclaw_global_essential("Average area/vol from fine not implemented for full octree\n");
        exit(0);
#endif

#endif  /* End PATCH_DIM == 3 */
    }

/* Compute volume from scratch in second layer of coarse grid ghost cells. These
   are not averaged from the fine grid (first layer can be averaged from fine
   grid, however)
*/
#if PATCH_DIM == 2
    metric_vt->compute_area_ghost(glob,coarse_patch,blockno,coarse_patchno);
#elif PATCH_DIM == 3
    metric_vt->compute_volume_ghost(glob,coarse_patch,blockno,coarse_patchno);
#endif

}

/* --------------------------------- Public interface  -------------------------------- */

void fclaw2d_metric_patch_compute_area (fclaw2d_global_t *glob,
                                       fclaw2d_patch_t* patch,
                                       int blockno, int patchno)
{
    fclaw2d_metric_vtable_t *metric_vt = fclaw2d_metric_vt(glob);
#if PATCH_DIM == 2
    FCLAW_ASSERT(metric_vt->compute_area);
    metric_vt->compute_area(glob,patch,blockno,patchno);
#elif PATCH_DIM == 3
    FCLAW_ASSERT(metric_vt->compute_volume);
    metric_vt->compute_volume(glob,patch,blockno,patchno);
#endif
}

void fclaw2d_metric_patch_build(fclaw2d_global_t* glob,
                                fclaw2d_patch_t* patch,
                                int blockno,
                                int patchno)
{
    fclaw2d_metric_vtable_t *metric_vt = fclaw2d_metric_vt(glob);
    FCLAW_ASSERT(metric_vt != NULL);

    /* Compute (xp,yp,zp) and (xd,yd,zd) */
    metric_vt->compute_mesh(glob,patch,blockno,patchno);

    /* Compute areas/volumes ($$$) from scratch.
       Note : These are all computed on finest level
       mesh and averaged down to coarser meshes.  This is
       required from geometric consistency */
#if PATCH_DIM == 2
    /* Compute 2d patch areas */
    metric_vt->compute_area(glob,patch,blockno,patchno);
#elif PATCH_DIM == 3
    /* Compute 3d volumes and 2d face areas */
    metric_vt->compute_volume(glob,patch,blockno,patchno);
#endif
    if (metric_vt->compute_basis != NULL)
    {
        /* In 2d : Surface normals, tangents, edge lengths,
           surface normals and curvature.

           In 3d : Rotation matrix at each face.
        */
        metric_vt->compute_basis(glob,patch,blockno,patchno);
    }
}

void fclaw2d_metric_patch_build_from_fine(fclaw2d_global_t *glob,
                                          fclaw2d_patch_t *fine_patches,
                                          fclaw2d_patch_t *coarse_patch,
                                          int blockno,
                                          int coarse_patchno,
                                          int fine0_patchno)
{
    /* This routine does a complete build using fine grid data to average
       volumes and in 3d, face areas */
    fclaw2d_metric_vtable_t *metric_vt = fclaw2d_metric_vt(glob);

    /* Compute xd,yd,zd, xp,yp,zp */
    metric_vt->compute_mesh(glob,coarse_patch,blockno,coarse_patchno);

    /* Compute areas/volumes by averaging from finer grids  */

    metric_average_area_from_fine(glob,fine_patches,coarse_patch,
                                  blockno, coarse_patchno,
                                  fine0_patchno);

    if (metric_vt->compute_basis != NULL)
    {
        /* In 2d : Surface normals and tangents at each face
           In 3d : Rotation matrix for each face.

           Note : These are not averaged from finer grids, but are
           built from scratch here.
        */
        metric_vt->compute_basis(glob,coarse_patch,blockno,coarse_patchno);
    }
}

/* ------------------------------------ Virtual table  -------------------------------- */

static
fclaw2d_metric_vtable_t* metric_vt_new()
{
    return (fclaw2d_metric_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_metric_vtable_t, 1);
}

static
void metric_vt_destroy(void* vt)
{
    FCLAW_FREE (vt);
}

fclaw2d_metric_vtable_t* fclaw2d_metric_vt(fclaw2d_global_t* glob)
{
	fclaw2d_metric_vtable_t* metric_vt = (fclaw2d_metric_vtable_t*)
	   							fclaw_pointer_map_get(glob->vtables, METRIC_VTABLE_NAME);
	FCLAW_ASSERT(metric_vt != NULL);
	FCLAW_ASSERT(metric_vt->is_set != 0);
	return metric_vt;
}

void fclaw2d_metric_vtable_initialize(fclaw2d_global_t* glob)
{
    fclaw2d_metric_vtable_t *metric_vt = metric_vt_new();

    /* Fortran files */
#if PATCH_DIM == 2
    metric_vt->compute_mesh          = fclaw2d_metric_compute_mesh_default;
    metric_vt->compute_area          = fclaw2d_metric_compute_area_default;
    metric_vt->compute_area_ghost    = fclaw2d_metric_compute_area_ghost_default;
    metric_vt->compute_basis       = fclaw2d_metric_compute_basis_default;

    metric_vt->fort_compute_mesh          = &FCLAW2D_METRIC_FORT_COMPUTE_MESH;
    metric_vt->fort_compute_normals       = &FCLAW2D_METRIC_FORT_COMPUTE_NORMALS;
    metric_vt->fort_compute_tangents      = &FCLAW2D_METRIC_FORT_COMPUTE_TANGENTS;
    metric_vt->fort_compute_surf_normals  = &FCLAW2D_METRIC_FORT_COMPUTE_SURF_NORMALS;
#elif PATCH_DIM == 3
    metric_vt->compute_mesh          = fclaw3d_metric_compute_mesh_default;
    metric_vt->compute_volume        = fclaw3d_metric_compute_volume_default;
    metric_vt->compute_volume_ghost  = fclaw3d_metric_compute_volume_ghost_default;
    metric_vt->compute_basis         = fclaw3d_metric_compute_basis_default;

    metric_vt->fort_compute_mesh     = &FCLAW3D_METRIC_FORT_COMPUTE_MESH;
    metric_vt->fort_compute_volume   = &FCLAW3D_METRIC_FORT_COMPUTE_VOLUME;
    metric_vt->fort_compute_basis    = &FCLAW3D_METRIC_FORT_COMPUTE_BASIS;

#endif

    metric_vt->is_set = 1;

	FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables,METRIC_VTABLE_NAME) == NULL);
	fclaw_pointer_map_insert(glob->vtables,METRIC_VTABLE_NAME, metric_vt, metric_vt_destroy);
}

/* --------------------------------- Misc access functions ---------------------------- */

/* These functions are not virtualized and are not defined by the
   patch interface */

fclaw2d_metric_patch_t* fclaw2d_metric_get_metric_patch(fclaw2d_global_t* glob,
                                                        fclaw2d_patch_t* patch)

{
    return get_metric_patch(glob, patch);
}

double* fclaw2d_metric_patch_get_area(fclaw2d_global_t* glob,
                                      fclaw2d_patch_t* patch)
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
#if PATCH_DIM == 2
    return mp->area.dataPtr();
#elif PATCH_DIM == 3
    return mp->volume.dataPtr();
#endif
}

/* ----------- See fclaw3d_metric.cpp for 3d versions of functions below -------------- */

#if PATCH_DIM == 2
void fclaw2d_metric_patch_scalar(fclaw2d_global_t* glob,
                                 fclaw2d_patch_t* patch,
                                 double **area, double** edgelengths,
                                 double **curvature)
#elif PATCH_DIM == 3
void fclaw3d_metric_patch_scalar(fclaw2d_global_t* glob,
                                 fclaw2d_patch_t* patch,
                                 double **volume, double** faceareas)
#endif
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
#if PATCH_DIM == 2
    *area = mp->area.dataPtr();
    *edgelengths =  mp->edge_lengths.dataPtr();
    *curvature = mp->curvature.dataPtr();
#elif PATCH_DIM == 3
    *volume = mp->volume.dataPtr();
    *faceareas =  mp->face_area.dataPtr();
#endif
}

#if PATCH_DIM == 2
void fclaw2d_metric_patch_vector(struct fclaw2d_global* glob,
                                 struct fclaw2d_patch* patch,
                                 double **xnormals, double **ynormals,
                                 double **xtangents, double **ytangents,
                                 double **surfnormals)
#elif PATCH_DIM == 3
void fclaw3d_metric_patch_basis(fclaw2d_global_t* glob,
                                fclaw2d_patch_t* patch,
                                double **xrot, double **yrot, double **zrot)
#endif
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
#if PATCH_DIM == 2
    *xnormals = mp->xface_normals.dataPtr();
    *ynormals = mp->yface_normals.dataPtr();
    *xtangents = mp->xface_tangents.dataPtr();
    *ytangents = mp->yface_tangents.dataPtr();
    *surfnormals = mp->surf_normals.dataPtr();
#elif PATCH_DIM == 3
    *xrot = mp->xrot.dataPtr();
    *yrot = mp->yrot.dataPtr();
    *zrot = mp->zrot.dataPtr();
#endif
}

#if PATCH_DIM == 2
void fclaw2d_metric_patch_grid_data(fclaw2d_global_t* glob,
                                    fclaw2d_patch_t* patch,
                                    int* mx, int* my, int* mbc,
                                    double* xlower, double* ylower,
                                    double* dx, double* dy)
#elif PATCH_DIM == 3
void fclaw3d_metric_patch_grid_data(fclaw2d_global_t* glob,
                                    fclaw2d_patch_t* patch,
                                    int* mx, int* my, int* mz,
                                    int* mbc,
                                    double* xlower, double* ylower, double *zlower,
                                    double* dx, double* dy, double* dz)
#endif
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
    *mx     = mp->mx;
    *my     = mp->my;
    *mbc    = mp->mbc;
    *xlower = mp->xlower;
    *ylower = mp->ylower;
    *dx     = mp->dx;
    *dy     = mp->dy;
#if PATCH_DIM == 3
    *mz     = mp->mz;
    *zlower = mp->zlower;
    *dz     = mp->dz;
#endif
}

#if PATCH_DIM == 2
void fclaw2d_metric_patch_mesh_data(fclaw2d_global_t* glob,
                                    fclaw2d_patch_t* patch,
                                    double **xp, double **yp, double **zp,
                                    double **xd, double **yd, double **zd,
                                    double **area)
#elif PATCH_DIM == 3
void fclaw3d_metric_patch_mesh_data(fclaw2d_global_t* glob,
                                    fclaw2d_patch_t* patch,
                                    double **xp, double **yp, double **zp,
                                    double **xd, double **yd, double **zd,
                                    double **volume, double** faceareas)
#endif
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
    *xp = mp->xp.dataPtr();
    *yp = mp->yp.dataPtr();
    *zp = mp->zp.dataPtr();
    *xd = mp->xd.dataPtr();
    *yd = mp->yd.dataPtr();
    *zd = mp->zd.dataPtr();
#if PATCH_DIM == 2
    *area = mp->area.dataPtr();
#elif PATCH_DIM == 3
    *volume = mp->volume.dataPtr();
    *faceareas = mp->face_area.dataPtr();
#endif
}

#if PATCH_DIM == 2
void fclaw2d_metric_patch_mesh_data2(fclaw2d_global_t* glob,
                                     fclaw2d_patch_t* patch,
                                     double **xnormals, double **ynormals,
                                     double **xtangents, double **ytangents,
                                     double **surfnormals,
                                     double **edgelengths, double **curvature)
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
    *xnormals    = mp->xface_normals.dataPtr();
    *ynormals    = mp->yface_normals.dataPtr();
    *xtangents   = mp->xface_tangents.dataPtr();
    *ytangents   = mp->yface_tangents.dataPtr();
    *surfnormals = mp->surf_normals.dataPtr();
    *curvature   = mp->curvature.dataPtr();
    *edgelengths = mp->edge_lengths.dataPtr();
}
#endif

int fclaw2d_metric_patch_nodes_size(fclaw2d_global_t* glob,
                                    fclaw2d_patch_t* patch)
{
    fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch);
    return mp->xd.size();
}


text:
amiGos

                    <input ng-model="searchFriend.name" ng-change="actionSearch()" ng-enter="actionSearch()" placeholder="Buscar personas" type="text" class="form-control">

                        <button class="btn btn-default" type="button" ng-click="actionSearch()">

                        </button>

                                {{friend.full_name}}

                                {{friend.total_post}} Posts
                                {{friend.total_friend}} Amigos

                                <button class="btn btn-xs btn-success">
                                     Mensaje
                                </button>
                                <button class="btn btn-xs btn-primary" ng-click="actionAdd(friend)" ng-if="myProfile.ref_profile_friend.indexOf(friend._id) == -1">
                                     Agregar
                                </button>
                                <button class="btn btn-xs btn-danger" ng-click="actionDelete(friend)" ng-if="myProfile.ref_profile_friend.indexOf(friend._id) != -1">
                                     Eliminar
                                </button>

                    <button class="btn btn-default btn-lg">

                    </button>


text:
<?php

namespace Luminary\Services\Generators\Creators\Validators;

use Luminary\Services\Generators\Creators\StubCreator;

class Validator extends StubCreator
{
    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub() :string
    {
        return __DIR__.'/stubs/validator.stub';
    }
}


text:
package flavor

type Flavor struct {
	ID   string
	Name string
}


text:
    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
    <title>PatternLayoutConverter Class</title>
    <xml>
    </xml>
    <link rel="stylesheet" type="text/css" href="MSDN.css" />

            log4net SDK Reference

PatternLayoutConverter Class

 Abstract class that provides the formatting functionality that derived classes need.

For a list of all members of this type, see PatternLayoutConverter Members.

        System.Object

   log4net.Util.PatternConverter
      log4net.Layout.Pattern.PatternLayoutConverter

        [Visual Basic]

MustInherit Public Class PatternLayoutConverter
    Inherits PatternConverter

        [C#]

public abstract class PatternLayoutConverter : PatternConverter

Thread Safety

This type is not safe for multithreaded operations.

Remarks

 Conversion specifiers in a conversion patterns are parsed to individual PatternConverters. Each of which is responsible for converting a logging event in a converter specific manner.

Requirements

        Namespace:
        log4net.Layout.Pattern

        Assembly: log4net (in log4net.dll)

See Also

        PatternLayoutConverter Members | log4net.Layout.Pattern Namespace

          Copyright 2001-2006 The Apache Software Foundation.

Generated from assembly log4net [1.2.10.0]