From 8f96cdf1cd0426310940c4122ff51e2b0dd1e02c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 10 Nov 2012 21:27:33 +0100 Subject: [PATCH] Setup activities --- .../osmand/binary/BinaryMapIndexReader.java | 6 ++ .../binary/BinaryMapRouteReaderAdapter.java | 19 +++--- .../src/net/osmand/binary/OsmandIndex.java | 5 +- .../osmand/router/RoutePlannerFrontEnd.java | 8 +-- .../osmand/router/RouteResultPreparation.java | 12 +++- DataExtractionOSM/src/osmand_index.proto | 2 +- .../osmand/plus/activities/MapActivity.java | 22 +++++++ ...arams.java => RouteCalculationParams.java} | 2 +- .../osmand/plus/routing/RouteProvider.java | 12 ++-- .../osmand/plus/routing/RoutingHelper.java | 46 +++++++++++++- Osmand-kernel/osmand/src/binaryRead.cpp | 2 - .../osmand/src/proto/osmand_index.pb.cpp | 63 ++++++++++++++----- .../osmand/src/proto/osmand_index.pb.h | 4 +- 13 files changed, 156 insertions(+), 47 deletions(-) rename OsmAnd/src/net/osmand/plus/routing/{RouteCalcuationParams.java => RouteCalculationParams.java} (95%) diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java index be7520787f..d3189dd94a 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexReader.java @@ -2001,4 +2001,10 @@ public class BinaryMapIndexReader { return Collections.emptyList(); } + public void initRouteRegion(RouteRegion routeReg) throws IOException { + if(routeAdapter != null){ + routeAdapter.initRouteRegion(routeReg); + } + } + } \ No newline at end of file diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java index a2f4a4e5c6..878f4a32fc 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java @@ -31,6 +31,7 @@ import net.osmand.osm.MapUtils; import org.apache.commons.logging.Log; import com.google.protobuf.CodedInputStreamRAF; +import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.WireFormat; public class BinaryMapRouteReaderAdapter { @@ -177,7 +178,7 @@ public class BinaryMapRouteReaderAdapter { return routeEncodingRules.get(id); } - public void initRouteEncodingRule(int id, String tags, String val) { + private void initRouteEncodingRule(int id, String tags, String val) { while(routeEncodingRules.size() <= id) { routeEncodingRules.add(null); } @@ -657,16 +658,20 @@ public class BinaryMapRouteReaderAdapter { public void initRouteTypesIfNeeded(SearchRequest req, List list) throws IOException { for (RouteSubregion rs : list) { if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) { - if (rs.routeReg.routeEncodingRules.isEmpty()) { - codedIS.seek(rs.routeReg.filePointer); - int oldLimit = codedIS.pushLimit(rs.routeReg.length); - readRouteIndex(rs.routeReg); - codedIS.popLimit(oldLimit); - } + initRouteRegion(rs.routeReg); } } } + public void initRouteRegion(RouteRegion routeReg) throws IOException, InvalidProtocolBufferException { + if (routeReg.routeEncodingRules.isEmpty()) { + codedIS.seek(routeReg.filePointer); + int oldLimit = codedIS.pushLimit(routeReg.length); + readRouteIndex(routeReg); + codedIS.popLimit(oldLimit); + } + } + public List loadRouteRegionData(RouteSubregion rs) throws IOException { TLongArrayList idMap = new TLongArrayList(); diff --git a/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java b/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java index cec2633676..ddfc7adf4a 100644 --- a/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java +++ b/DataExtractionOSM/src/net/osmand/binary/OsmandIndex.java @@ -3636,7 +3636,7 @@ public final class OsmandIndex { public boolean hasOffset() { return hasOffset; } public long getOffset() { return offset_; } - // required bool basemap = 3; + // optional bool basemap = 3; public static final int BASEMAP_FIELD_NUMBER = 3; private boolean hasBasemap; private boolean basemap_ = false; @@ -3684,7 +3684,6 @@ public final class OsmandIndex { public final boolean isInitialized() { if (!hasSize) return false; if (!hasOffset) return false; - if (!hasBasemap) return false; if (!hasLeft) return false; if (!hasRight) return false; if (!hasTop) return false; @@ -4032,7 +4031,7 @@ public final class OsmandIndex { return this; } - // required bool basemap = 3; + // optional bool basemap = 3; public boolean hasBasemap() { return result.hasBasemap(); } diff --git a/DataExtractionOSM/src/net/osmand/router/RoutePlannerFrontEnd.java b/DataExtractionOSM/src/net/osmand/router/RoutePlannerFrontEnd.java index 80416de5da..59e24e8738 100644 --- a/DataExtractionOSM/src/net/osmand/router/RoutePlannerFrontEnd.java +++ b/DataExtractionOSM/src/net/osmand/router/RoutePlannerFrontEnd.java @@ -5,16 +5,16 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.apache.commons.logging.Log; - import net.osmand.LogUtil; import net.osmand.binary.BinaryMapRouteReaderAdapter; -import net.osmand.binary.RouteDataObject; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; +import net.osmand.binary.RouteDataObject; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; import net.osmand.router.BinaryRoutePlanner.RouteSegment; +import org.apache.commons.logging.Log; + public class RoutePlannerFrontEnd { private boolean useOldVersion; @@ -181,7 +181,7 @@ public class RoutePlannerFrontEnd { } - private List runNativeRouting(final RoutingContext ctx, boolean leftSideNavigation) { + private List runNativeRouting(final RoutingContext ctx, boolean leftSideNavigation) throws IOException { refreshProgressDistance(ctx); RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]); RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY, diff --git a/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java b/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java index 8a5f9d5484..1eb1154494 100644 --- a/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java +++ b/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java @@ -1,5 +1,6 @@ package net.osmand.router; +import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -7,6 +8,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.RouteDataObject; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; @@ -20,13 +22,13 @@ public class RouteResultPreparation { /** * Helper method to prepare final result */ - List prepareResult(RoutingContext ctx, FinalRouteSegment finalSegment,boolean leftside) { + List prepareResult(RoutingContext ctx, FinalRouteSegment finalSegment,boolean leftside) throws IOException { List result = convertFinalSegmentToResults(ctx, finalSegment); prepareResult(ctx, leftside, result); return result; } - List prepareResult(RoutingContext ctx, boolean leftside, List result) { + List prepareResult(RoutingContext ctx, boolean leftside, List result) throws IOException { validateAllPointsConnected(result); // calculate time calculateTimeSpeedAndAttachRoadSegments(ctx, result); @@ -35,13 +37,17 @@ public class RouteResultPreparation { return result; } - private void calculateTimeSpeedAndAttachRoadSegments(RoutingContext ctx, List result) { + private void calculateTimeSpeedAndAttachRoadSegments(RoutingContext ctx, List result) throws IOException { for (int i = 0; i < result.size(); i++) { if(ctx.checkIfMemoryLimitCritical(ctx.config.memoryLimitation)) { ctx.unloadUnusedTiles(ctx.config.memoryLimitation); } RouteSegmentResult rr = result.get(i); RouteDataObject road = rr.getObject(); + BinaryMapIndexReader reader = ctx.reverseMap.get(road.region); + if(reader != null) { + reader.initRouteRegion(road.region); + } double distOnRoadToPass = 0; double speed = ctx.getRouter().defineSpeed(road); if (speed == 0) { diff --git a/DataExtractionOSM/src/osmand_index.proto b/DataExtractionOSM/src/osmand_index.proto index aa244f80b0..0fa10ff720 100644 --- a/DataExtractionOSM/src/osmand_index.proto +++ b/DataExtractionOSM/src/osmand_index.proto @@ -75,7 +75,7 @@ message MapPart { message RoutingSubregion { required int64 size = 1; required int64 offset = 2; - required bool basemap= 3; + optional bool basemap= 3; required int32 left = 4; required int32 right = 5; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f8d01197c1..600cc57562 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -66,17 +66,22 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; +import android.util.DisplayMetrics; import android.util.Log; +import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; +import android.view.ViewGroup.LayoutParams; import android.view.Window; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.Transformation; +import android.widget.FrameLayout; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -199,6 +204,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe savingTrackHelper = getMyApplication().getSavingTrackHelper(); liveMonitoringHelper = getMyApplication().getLiveMonitoringHelper(); routingHelper = getMyApplication().getRoutingHelper(); + createProgressBarForRouting(); // This situtation could be when navigation suddenly crashed and after restarting // it tries to continue the last route if(settings.FOLLOW_THE_ROUTE.get() && !routingHelper.isRouteCalculated()){ @@ -234,6 +240,22 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe OsmandPlugin.onMapActivityCreate(this); } + private void createProgressBarForRouting() { + FrameLayout parent = (FrameLayout) mapView.getParent(); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, + Gravity.CENTER_HORIZONTAL | Gravity.TOP); + DisplayMetrics dm = getResources().getDisplayMetrics(); + params.topMargin = (int) (100 * dm.density); + ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); + pb.setIndeterminate(false); + pb.setMax(100); + pb.setLayoutParams(params); + pb.setVisibility(View.GONE); + + parent.addView(pb); + routingHelper.setProgressBar(pb, new Handler()); + } + @SuppressWarnings("rawtypes") public Object getLastNonConfigurationInstanceByKey(String key) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalcuationParams.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java similarity index 95% rename from OsmAnd/src/net/osmand/plus/routing/RouteCalcuationParams.java rename to OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java index 93bb7f417d..b47d3c5c14 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalcuationParams.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java @@ -10,7 +10,7 @@ import net.osmand.router.RouteCalculationProgress; import android.content.Context; import android.location.Location; -public class RouteCalcuationParams { +public class RouteCalculationParams { public Location start; public LatLon end; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index b8c6ee9db6..19252724d9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -145,7 +145,7 @@ public class RouteProvider { - public RouteCalculationResult calculateRouteImpl(RouteCalcuationParams params){ + public RouteCalculationResult calculateRouteImpl(RouteCalculationParams params){ long time = System.currentTimeMillis(); if (params.start != null && params.end != null) { if(log.isInfoEnabled()){ @@ -181,7 +181,7 @@ public class RouteProvider { } - private RouteCalculationResult calculateGpxRoute(RouteCalcuationParams pars) { + private RouteCalculationResult calculateGpxRoute(RouteCalculationParams pars) { RouteCalculationResult res; // get the closest point to start and to end float minDist = Integer.MAX_VALUE; @@ -247,7 +247,7 @@ public class RouteProvider { - protected RouteCalculationResult findYOURSRoute(RouteCalcuationParams params) throws MalformedURLException, IOException, + protected RouteCalculationResult findYOURSRoute(RouteCalculationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException { List res = new ArrayList(); StringBuilder uri = new StringBuilder(); @@ -306,7 +306,7 @@ public class RouteProvider { params.ctx, params.leftSide, true); } - protected RouteCalculationResult findVectorMapsRoute(RouteCalcuationParams params) throws IOException { + protected RouteCalculationResult findVectorMapsRoute(RouteCalculationParams params) throws IOException { OsmandApplication app = (OsmandApplication) params.ctx.getApplicationContext(); BinaryMapIndexReader[] files = app.getResourceManager().getRoutingMapFiles(); RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(true); @@ -411,7 +411,7 @@ public class RouteProvider { } - protected RouteCalculationResult findCloudMadeRoute(RouteCalcuationParams params) + protected RouteCalculationResult findCloudMadeRoute(RouteCalculationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException { List res = new ArrayList(); List directions = null; @@ -578,7 +578,7 @@ public class RouteProvider { return directions; } - protected RouteCalculationResult findORSRoute(RouteCalcuationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, + protected RouteCalculationResult findORSRoute(RouteCalculationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException { List res = new ArrayList(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 81dcf70b86..5e845e979f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -26,6 +26,8 @@ import android.content.Context; import android.content.Intent; import android.location.Location; import android.os.Handler; +import android.view.View; +import android.widget.ProgressBar; import android.widget.Toast; public class RoutingHelper { @@ -70,6 +72,9 @@ public class RoutingHelper { private boolean makeUturnWhenPossible = false; private long makeUTwpDetected = 0; + private ProgressBar progress; + private Handler progressHandler; + public boolean makeUturnWhenPossible() { @@ -570,9 +575,9 @@ public class RoutingHelper { private class RouteRecalculationThread extends Thread { private boolean interrupted = false; - private final RouteCalcuationParams params; + private final RouteCalculationParams params; - public RouteRecalculationThread(String name, RouteCalcuationParams params) { + public RouteRecalculationThread(String name, RouteCalculationParams params) { super(name); this.params = params; if(params.calculationProgress == null) { @@ -629,7 +634,7 @@ public class RoutingHelper { if(currentRunningJob == null){ // do not evaluate very often if (System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) { - RouteCalcuationParams params = new RouteCalcuationParams(); + RouteCalculationParams params = new RouteCalculationParams(); params.start = start; params.end = end; params.intermediates = intermediates; @@ -641,6 +646,10 @@ public class RoutingHelper { params.type = settings.ROUTER_SERVICE.getModeValue(mode); params.mode = mode; params.ctx = app; + if(previousRoute == null && params.type == RouteService.OSMAND) { + params.calculationProgress = new RouteCalculationProgress(); + updateProgress(params.calculationProgress); + } synchronized (this) { currentRunningJob = new RouteRecalculationThread("Calculating route", params); //$NON-NLS-1$ currentRunningJob.start(); @@ -650,6 +659,29 @@ public class RoutingHelper { } + private void updateProgress(final RouteCalculationProgress calculationProgress) { + if(progress != null) { + progressHandler.postDelayed(new Runnable() { + @Override + public void run() { + if (isRouteBeingCalculated()) { + progress.setVisibility(View.VISIBLE); + float p = calculationProgress.distanceFromBegin + calculationProgress.distanceFromEnd; + float all = calculationProgress.totalEstimatedDistance * 1.5f; + if (all > 0) { + int t = (int) Math.min(p * p / (all * all) * 100f, 99); + progress.setProgress(t); + updateProgress(calculationProgress); + } + } else { + progress.setVisibility(View.GONE); + } + } + }, 300); + } + } + + public boolean isRouteBeingCalculated(){ return currentRunningJob != null; } @@ -682,4 +714,12 @@ public class RoutingHelper { } + + public void setProgressBar(ProgressBar pb, Handler handler) { + progress = pb; + progressHandler = handler; + + } + + } diff --git a/Osmand-kernel/osmand/src/binaryRead.cpp b/Osmand-kernel/osmand/src/binaryRead.cpp index 6fc3b213ab..0f38619ac9 100644 --- a/Osmand-kernel/osmand/src/binaryRead.cpp +++ b/Osmand-kernel/osmand/src/binaryRead.cpp @@ -1007,7 +1007,6 @@ void searchRouteSubregions(SearchQuery* q, std::vector& tempResu void readRouteMapObjects(SearchQuery* q, BinaryMapFile* file, vector& found, RoutingIndex* routeIndex, std::vector& tempResult, bool skipDuplicates, IDS_SET& ids) { - osmand_log_print(LOG_INFO, "Search map %s %d", routeIndex->name.c_str(), found.size()); sort(found.begin(), found.end(), sortRouteRegions); lseek(file->fd, 0, SEEK_SET); FileInputStream input(file->fd); @@ -1045,7 +1044,6 @@ void readRouteDataAsMapObjects(SearchQuery* q, BinaryMapFile* file, std::vector< contains = true; } } - osmand_log_print(LOG_INFO, "Search map %s %d", (*routeIndex)->name.c_str(), subs.size()); if (contains) { vector found; lseek(file->fd, 0, SEEK_SET); diff --git a/Osmand-kernel/osmand/src/proto/osmand_index.pb.cpp b/Osmand-kernel/osmand/src/proto/osmand_index.pb.cpp index 2df8e7dc30..b43fbf40aa 100644 --- a/Osmand-kernel/osmand/src/proto/osmand_index.pb.cpp +++ b/Osmand-kernel/osmand/src/proto/osmand_index.pb.cpp @@ -2373,6 +2373,7 @@ void MapPart::Swap(MapPart* other) { #ifndef _MSC_VER const int RoutingSubregion::kSizeFieldNumber; const int RoutingSubregion::kOffsetFieldNumber; +const int RoutingSubregion::kBasemapFieldNumber; const int RoutingSubregion::kLeftFieldNumber; const int RoutingSubregion::kRightFieldNumber; const int RoutingSubregion::kTopFieldNumber; @@ -2398,6 +2399,7 @@ void RoutingSubregion::SharedCtor() { _cached_size_ = 0; size_ = GOOGLE_LONGLONG(0); offset_ = GOOGLE_LONGLONG(0); + basemap_ = false; left_ = 0; right_ = 0; top_ = 0; @@ -2434,6 +2436,7 @@ void RoutingSubregion::Clear() { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { size_ = GOOGLE_LONGLONG(0); offset_ = GOOGLE_LONGLONG(0); + basemap_ = false; left_ = 0; right_ = 0; top_ = 0; @@ -2476,6 +2479,22 @@ bool RoutingSubregion::MergePartialFromCodedStream( } else { goto handle_uninterpreted; } + if (input->ExpectTag(24)) goto parse_basemap; + break; + } + + // optional bool basemap = 3; + case 3: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + parse_basemap: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &basemap_))); + _set_bit(2); + } else { + goto handle_uninterpreted; + } if (input->ExpectTag(32)) goto parse_left; break; } @@ -2488,7 +2507,7 @@ bool RoutingSubregion::MergePartialFromCodedStream( DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &left_))); - _set_bit(2); + _set_bit(3); } else { goto handle_uninterpreted; } @@ -2504,7 +2523,7 @@ bool RoutingSubregion::MergePartialFromCodedStream( DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &right_))); - _set_bit(3); + _set_bit(4); } else { goto handle_uninterpreted; } @@ -2520,7 +2539,7 @@ bool RoutingSubregion::MergePartialFromCodedStream( DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &top_))); - _set_bit(4); + _set_bit(5); } else { goto handle_uninterpreted; } @@ -2536,7 +2555,7 @@ bool RoutingSubregion::MergePartialFromCodedStream( DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &bottom_))); - _set_bit(5); + _set_bit(6); } else { goto handle_uninterpreted; } @@ -2552,7 +2571,7 @@ bool RoutingSubregion::MergePartialFromCodedStream( DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &shiftodata_))); - _set_bit(6); + _set_bit(7); } else { goto handle_uninterpreted; } @@ -2587,28 +2606,33 @@ void RoutingSubregion::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->offset(), output); } - // required int32 left = 4; + // optional bool basemap = 3; if (_has_bit(2)) { + ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->basemap(), output); + } + + // required int32 left = 4; + if (_has_bit(3)) { ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->left(), output); } // required int32 right = 5; - if (_has_bit(3)) { + if (_has_bit(4)) { ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->right(), output); } // required int32 top = 6; - if (_has_bit(4)) { + if (_has_bit(5)) { ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->top(), output); } // required int32 bottom = 7; - if (_has_bit(5)) { + if (_has_bit(6)) { ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->bottom(), output); } // required uint32 shifToData = 8; - if (_has_bit(6)) { + if (_has_bit(7)) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->shiftodata(), output); } @@ -2632,6 +2656,11 @@ int RoutingSubregion::ByteSize() const { this->offset()); } + // optional bool basemap = 3; + if (has_basemap()) { + total_size += 1 + 1; + } + // required int32 left = 4; if (has_left()) { total_size += 1 + @@ -2689,18 +2718,21 @@ void RoutingSubregion::MergeFrom(const RoutingSubregion& from) { set_offset(from.offset()); } if (from._has_bit(2)) { - set_left(from.left()); + set_basemap(from.basemap()); } if (from._has_bit(3)) { - set_right(from.right()); + set_left(from.left()); } if (from._has_bit(4)) { - set_top(from.top()); + set_right(from.right()); } if (from._has_bit(5)) { - set_bottom(from.bottom()); + set_top(from.top()); } if (from._has_bit(6)) { + set_bottom(from.bottom()); + } + if (from._has_bit(7)) { set_shiftodata(from.shiftodata()); } } @@ -2713,7 +2745,7 @@ void RoutingSubregion::CopyFrom(const RoutingSubregion& from) { } bool RoutingSubregion::IsInitialized() const { - if ((_has_bits_[0] & 0x0000007f) != 0x0000007f) return false; + if ((_has_bits_[0] & 0x000000fb) != 0x000000fb) return false; return true; } @@ -2722,6 +2754,7 @@ void RoutingSubregion::Swap(RoutingSubregion* other) { if (other != this) { std::swap(size_, other->size_); std::swap(offset_, other->offset_); + std::swap(basemap_, other->basemap_); std::swap(left_, other->left_); std::swap(right_, other->right_); std::swap(top_, other->top_); diff --git a/Osmand-kernel/osmand/src/proto/osmand_index.pb.h b/Osmand-kernel/osmand/src/proto/osmand_index.pb.h index 9daee90189..6d56d8d1bf 100644 --- a/Osmand-kernel/osmand/src/proto/osmand_index.pb.h +++ b/Osmand-kernel/osmand/src/proto/osmand_index.pb.h @@ -962,7 +962,7 @@ class RoutingSubregion : public ::google::protobuf::MessageLite { inline ::google::protobuf::int64 offset() const; inline void set_offset(::google::protobuf::int64 value); - // required bool basemap = 3; + // optional bool basemap = 3; inline bool has_basemap() const; inline void clear_basemap(); static const int kBasemapFieldNumber = 3; @@ -2216,7 +2216,7 @@ inline void RoutingSubregion::set_offset(::google::protobuf::int64 value) { offset_ = value; } -// required bool basemap = 3; +// optional bool basemap = 3; inline bool RoutingSubregion::has_basemap() const { return _has_bit(2); }