From c3472fcee1952812ed079500b27b667e19bed65d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 6 Sep 2010 22:11:37 +0000 Subject: [PATCH] implement render further git-svn-id: https://osmand.googlecode.com/svn/trunk@490 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- .../src/net/osmand/ToDoConstants.java | 24 +- OsmAnd/res/drawable/h_embassy.png | Bin 0 -> 2893 bytes OsmAnd/res/drawable/h_grave_yard.png | Bin 0 -> 291 bytes OsmAnd/res/drawable/h_hospital.png | Bin 0 -> 557 bytes OsmAnd/res/drawable/h_library.png | Bin 0 -> 715 bytes OsmAnd/res/drawable/h_pharmacy.png | Bin 0 -> 341 bytes OsmAnd/res/drawable/h_pub.png | Bin 0 -> 433 bytes OsmAnd/res/drawable/h_recycling.png | Bin 0 -> 562 bytes OsmAnd/res/drawable/h_school.png | Bin 0 -> 3136 bytes OsmAnd/res/drawable/h_telephone.png | Bin 0 -> 444 bytes OsmAnd/res/values-ru/strings.xml | 1 + OsmAnd/res/values/strings.xml | 1 + OsmAnd/src/net/osmand/OsmandSettings.java | 8 +- OsmAnd/src/net/osmand/ResourceManager.java | 25 +- .../net/osmand/activities/MapActivity.java | 41 +- .../osmand/activities/OsmandApplication.java | 4 +- .../osmand/activities/SettingsActivity.java | 61 ++- ...tories.java => MapRenderRepositories.java} | 112 +++--- .../src/net/osmand/render/OsmandRenderer.java | 364 ++++++++++-------- .../src/net/osmand/render/RendererLayer.java | 5 +- .../net/osmand/views/OsmandMapTileView.java | 65 ++-- 21 files changed, 416 insertions(+), 295 deletions(-) create mode 100644 OsmAnd/res/drawable/h_embassy.png create mode 100644 OsmAnd/res/drawable/h_grave_yard.png create mode 100644 OsmAnd/res/drawable/h_hospital.png create mode 100644 OsmAnd/res/drawable/h_library.png create mode 100644 OsmAnd/res/drawable/h_pharmacy.png create mode 100644 OsmAnd/res/drawable/h_pub.png create mode 100644 OsmAnd/res/drawable/h_recycling.png create mode 100644 OsmAnd/res/drawable/h_school.png create mode 100644 OsmAnd/res/drawable/h_telephone.png rename OsmAnd/src/net/osmand/render/{RenderMapsRepositories.java => MapRenderRepositories.java} (63%) diff --git a/DataExtractionOSM/src/net/osmand/ToDoConstants.java b/DataExtractionOSM/src/net/osmand/ToDoConstants.java index 7ce310c532..2125fa7c64 100644 --- a/DataExtractionOSM/src/net/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/net/osmand/ToDoConstants.java @@ -16,23 +16,30 @@ public class ToDoConstants { // railway( station, subway?) - issue 17 // 86. Allow to add/edit custom tags to POI objects. // 87. Use network availability for defining loading tiles from internet. + // 88. Implement show gpx track from folder and navigate using gpx track. + // 89. Transport redesign UI (enable run from context menu, switch go to goal/not) ! + + // TODO small improvements for release : + // 1. If select vector map, notice if there are no loaded maps. // TODO Improvements: // 1! VELCOM // 2. rotate map gps without location - // 3! Transport redesign call UI (enable context menu call, switch go to goal/not) - // 4. recalculating route when location is far from ! + // 4. recalculating route when location is far from ! (error) // 5. keyboard (issue 43 )? // 6. Do not upload empty files (transport, poi... ). // 7. Implement auto-delete from site (done, should be ported from C#) + // 8. In all places verify to use float lat/lon improve disk space for indexes !!! + // 13! Support multiple database for map rendering - // 8. In all places verify to use float lat/lon improve usage indexes !!! // + 9. Render map on bitmap in another thread // + 10. Sort objects before render (according layering) - // 11!! Investigate ResourceManager close methods and clear cache when Map switches !!! - // 12! When switch to map check that indexes were loaded !! - - // 11. Move JUnidecode on client save space for some indexes + // + 11!! Investigate ResourceManager close methods and clear cache when Map switches !!! (MAP SWITCH, update settings) + // + 12! When switch to map check that indexes were loaded !! + // + 14. Rotate vector map + // 15. Draw layers -> icons -> text. See intersects of double streets. + + // 11. Move JUnidecode on client save space for some indexes adn // 12. Fix : find proper location for streets ! centralize them (when create index)? // TODO Check @@ -49,12 +56,13 @@ public class ToDoConstants { // Not clear if it is really needed // 69. Add phone information to POI - // 70. Show building numbers over map (require changing address index - index 2 more columns lat/lon for fast search) // 66. Transport routing (show next stop, total distance, show stop get out, voice) (needed ?). // 85. Enable on/off screen for bike navigation (?) // 83. Add monitoring service to send locations to internet (?) // DONE ANDROID : + // 70. Show building numbers over map (require changing address index - index 2 more columns lat/lon for fast search). + // (Not needed, because of vector rendering) // 82. Rotate map according compass // 85. Remove context menu on long press map ! Accumulate actions and show label (+) diff --git a/OsmAnd/res/drawable/h_embassy.png b/OsmAnd/res/drawable/h_embassy.png new file mode 100644 index 0000000000000000000000000000000000000000..909e8dc125588a90ff481deef346bf0474413545 GIT binary patch literal 2893 zcmV-T3$pZyP)z>>PiaF#P*7-ZbZ>KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxr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+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0001ZNklW2N)O_9x^a6 z@G~$lI503U7@!$Z&w|8JU|?WKU?2dP7)S(zPy-7A`2!3L3}kLNhq)B7{pyA+00000NkvXXu0mjfS(Z&M literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_grave_yard.png b/OsmAnd/res/drawable/h_grave_yard.png new file mode 100644 index 0000000000000000000000000000000000000000..74995335bdf9482df810ad8444d4de21c6d76b10 GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf4nJ zu-yV-MprN24?sc564!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1SRc)B=- zSoB_J~M4DD}DY&~On=mij7fg$w_V g^X=Q;e6KFVdQ&MBb@08n0RegFUf literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_hospital.png b/OsmAnd/res/drawable/h_hospital.png new file mode 100644 index 0000000000000000000000000000000000000000..dd4febf2bd3604768042a755497a7401b7dd1664 GIT binary patch literal 557 zcmV+|0@D47P)LlRsz_K^Vn<-|TMgBzS^< zKt&N_mMdZr2na$1EdoNoN;@rLBTCqq2!f5Ix=?l!r@m?(MG@D1XD&-Tvus}}0D!L-bbDv;g(|`}m?n+AXxZV*EQtSs^Jjj)wn^y+CT>Yk~Tjkzf0Jm9$ zb1r7JQloTBF$sXeNzm5q^kT^Lsa8ftX}mCG&H_)|)-dOi*`wG(YHDv+&}->h(I3$L z&=L)IbRekVA7n71#9biK8Un~t44)0jvGtSOOM*@|5x8JTUboP2;0U;H+XD2N1Lu9l z@23G(O3NvTgIV$kKBjvi<&hn%7S<4af=>W7%7?Z>2r2dpEFNa!S4RiE?4JfMhZK97 zofrdr0lvm00`Q*FfZ`1L1W!|6$5U2RYLrI>vs+2#VzlO<#^4>d*wes#p0P^1XT#4l v&)x1U*&(n!2C*RTBEHY{F&S-z_}}^sJo}h|Bl)k~00000NkvXXu0mjfS+Djf literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_library.png b/OsmAnd/res/drawable/h_library.png new file mode 100644 index 0000000000000000000000000000000000000000..b38c4d156e0ea531f20328267c661dee8203f439 GIT binary patch literal 715 zcmV;+0yO=JP)TluJm|Q51*2-~G>wV`Hs) zuYzLefe=AaWH3F+L08tUBHASpDbW*Zz@Uw2P_!s2Xi=23$;z;T2zpQmJ!q3Hq9@ft zO3|^I`#&ujBW*@qcs7@N9^XCZ-g6I3uxKoY`VNGN^Yo4 zY;Zom7nA~`#R5$9S!f4aI|fgUnqgx)e$<(r04*q$c_D)sXld2F*y~4cbKN8D4j_{v z?nEB(q7-NtR7~^Ew>G3>l|_LA5z5TiDGSaEJs%eoB?E$s_36aS|9}7nF~c8m=9_{4 zN+~9WEiRXD%cO`81NKKTOa{!!%N_DT&?NDBJW!0P-bDNYg$H&3Cp-9w3$FrRurTm` zm*uSq)H60wJ(9xA=09EWx8#KxW$Fi?V&Lw3iz@R)g<{f%j{VL-qp zC$d|??iNm77eXbnbATTK>k3T=2^Do-8y)s)(vR;p5=f?vU%r2EGw`&asw=G53itIv zX3Y@3bXbka+6B>2!MEm4`k_bzKY2%X?fl5SoUvXo15_!(E0XJ$bi<4_GCf1g1!hV1 z1!GC&g8bF4H{?oAn|;;M~SDf$X}ORvUI-C~1yKeP6SiPCm##`!{aPdDu{0wkvS%u+N99_viX literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_pharmacy.png b/OsmAnd/res/drawable/h_pharmacy.png new file mode 100644 index 0000000000000000000000000000000000000000..fb1c56c8655a9d225c9c48c671dd2b2555f0b745 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt`aC7!;n z>^C@N#27RCg)*)hf$``iCWS?cy_uK7zavejPjQqKUuXD>aZ!UX2 zpEs1NIr(VRu5yp}F&WZpe(f~dD)`s)U)}BIC#F&gD;lqg?+7}`sd~Wu!29_OR?N~2 zyASlK&u^GqvnZ|DV-cg~+~5=Sjw?7Sd`|9~m(Qtnu_0lyX2IKowIQNSf_pVz7|C(9 l+7mFVre{C9B`d(;BkqGR&aCcq$I@O1TaS?83{1OVl7ikAQY literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_pub.png b/OsmAnd/res/drawable/h_pub.png new file mode 100644 index 0000000000000000000000000000000000000000..b452a7eadc5971e8038982b672449b913a0b318d GIT binary patch literal 433 zcmV;i0Z#sjP)Lk-ctHK@f$%GxuIQaun>O zfevCvX(Pgmz)Pf#lqL-nlt_qz&JVx?pa@E;R1p$=lxxQY5(+{>cH;PNhK7jb+7}m@ zZFY|4e0z2m?pZ1d`_CJVWPDwBk)$4)ngSqmjmd_;-+ZLM5U}@*Z0+I7PvF7-&x~(x zKaHN=bau08e`ONTkBC7~Sfc0fCE!@-*KJ&S7f#oiy&{rbLydr*n4OF#lOF&TtG@75 zJEZ^Hx6eCw#sgwh$k}Tr2s)LtQ6qEHbJKpfU6TmvkV}q zIf|q_fv0pNwilUG%N_y#{`26X6!7k7_+7!q1XhcHK%0W|qHc3@(5qRsH5cD#IXYVg zK%xWlKcUcL;dxO{i$a8QOL$#LRu2A|0b(8Taw#B5hlf+o+D2L<;_q9iKf|x;m*dmo b{JrZBS`~W&*1nU-00000NkvXXu0mjf{SCSg literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_recycling.png b/OsmAnd/res/drawable/h_recycling.png new file mode 100644 index 0000000000000000000000000000000000000000..59eb331aaa16521883dab2d046af93a384335d90 GIT binary patch literal 562 zcmV-20?qx2P)rkuhsiQ5c4w@1#lYjR{VQ zDCkftLKP9B77=lhdZi8yA}&rM2uj;T6f88jh}L9LP=A09793jBEDk}7lN7{)Sbu;n z4o%wLd(-B84rwlF+QCk~(>Wi{`*Obb!2gzPH5|Q|yd-KKf_(|{0zgHcm&*R_ZZ_6E zxOI+nJRYwAeW)yn@EzzE$e!-&iJv)~Sp2-O`m4>G?tql*+z0jnsF8QXxCewSR*y_f zugrDwn*vm13Gfv@mCF7kO*tVjB`|4}{FWUQhDZf=XA&SxEe46e-L=}ZPH84w*wD=d zcR)mk8yZ}HRv`rF0jQHnp}{MV%Vyb`cUS!5kE^V8nsc6W7PJaT0(TDlC(#PU>G~g# zz3Xg$EtS04{nX6KU>0cYFZv*VKD|2%7#?&E00RK3j0^IOjbALwUy{8>7y%T>sA(Re z6Uuq+l%mHBas|;$YifT#EjQ-#o_o#0DTG;r9#zYaVkLMTbpT+D%~@qo;R8wjIO$Xk358KmSZ^xc(oBl07*qoM6N<$f(bzF AVE_OC literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable/h_school.png b/OsmAnd/res/drawable/h_school.png new file mode 100644 index 0000000000000000000000000000000000000000..4c919bfdd3306e49317a9362a281318447b90897 GIT binary patch literal 3136 zcmV-G48QYKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+B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!Q5462_j#?>S3(-G zFc9KnHPyf%O-f>7FHlf)!3N!nnciOtaVRbKBgcuh#F zt#GDubN;_y?ztEKSgM*(c-%9JFe%`6Db_b))MsUJQ8K#kAuHJpdT$PPFs^&4|7) zl|U;xomS9XYVyg&aj(C6fnj{^D@GK9IUr}&sHdt0=~VVsAx9|P0knuxp{?W0OC>?k mH)`8+AdrfjS~Hd4f2j}axOVjyCk_Vy0000 + Векторные osm карты Искать транспорт на остановке Точка на карте\n Ш {0,number,#.####} Д {1,number,#.####} Bug diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index e05e6df664..bea606fe68 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,5 +1,6 @@ + Vector osm maps Search transport at stop Point on map\n Lat {0,number,#.####} lon {1,number,#.####} Bug diff --git a/OsmAnd/src/net/osmand/OsmandSettings.java b/OsmAnd/src/net/osmand/OsmandSettings.java index 6ad5e25ad7..90eba1441a 100644 --- a/OsmAnd/src/net/osmand/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/OsmandSettings.java @@ -322,7 +322,13 @@ public class OsmandSettings { } // this value string is synchronized with settings_pref.xml preference name + public static final String MAP_VECTOR_DATA = "map_vector_data"; //$NON-NLS-1$ public static final String MAP_TILE_SOURCES = "map_tile_sources"; //$NON-NLS-1$ + + public static boolean isUsingMapVectorData(Context ctx){ + SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); + return prefs.getBoolean(MAP_VECTOR_DATA, false); + } public static ITileSource getMapTileSource(Context ctx) { SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); @@ -358,7 +364,7 @@ public class OsmandSettings { return new TileSourceManager.TileSourceTemplate(dir.getName(), url); } } - + } return TileSourceManager.getMapnikSource(); } diff --git a/OsmAnd/src/net/osmand/ResourceManager.java b/OsmAnd/src/net/osmand/ResourceManager.java index 9a406c6022..ac9d8589ac 100644 --- a/OsmAnd/src/net/osmand/ResourceManager.java +++ b/OsmAnd/src/net/osmand/ResourceManager.java @@ -21,7 +21,7 @@ import net.osmand.data.preparation.MapTileDownloader.IMapDownloaderCallback; import net.osmand.map.ITileSource; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; -import net.osmand.render.RenderMapsRepositories; +import net.osmand.render.MapRenderRepositories; import net.osmand.views.POIMapLayer; import org.apache.commons.logging.Log; @@ -49,6 +49,7 @@ public class ResourceManager { public static final String TRANSPORT_PATH = APP_DIR + IndexConstants.TRANSPORT_INDEX_DIR; public static final String TILES_PATH = APP_DIR+"tiles/"; //$NON-NLS-1$ public static final String TEMP_SOURCE_TO_LOAD = "temp"; //$NON-NLS-1$ + public static final String VECTOR_MAP = "#vector_map"; //$NON-NLS-1$ public static final int LIMIT_TRANSPORT = 200; @@ -82,14 +83,14 @@ public class ResourceManager { protected final Map transportRepositories = new LinkedHashMap(); - protected final RenderMapsRepositories renderer ; + protected final MapRenderRepositories renderer ; public final AsyncLoadingThread asyncLoadingTiles = new AsyncLoadingThread(); public ResourceManager(Context context) { this.context = context; - this.renderer = new RenderMapsRepositories(context); + this.renderer = new MapRenderRepositories(context); // TODO start/stop this thread when needed? asyncLoadingTiles.start(); dirWithTiles = new File(Environment.getExternalStorageDirectory(), TILES_PATH); @@ -526,14 +527,14 @@ public class ResourceManager { } ////////////////////////////////////////////// Working with map //////////////////////////////////////////////// - public void updateRendererIfNeeded(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom){ - if(!renderer.updateMapIsNotNeeded(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom)){ + public void updateRendererIfNeeded(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, float rotate){ + if(!renderer.updateMapIsNotNeeded(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, rotate)){ asyncLoadingTiles.requestToLoadMap( - new MapLoadRequest(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom)); + new MapLoadRequest(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom, rotate)); } } - public RenderMapsRepositories getRenderer() { + public MapRenderRepositories getRenderer() { return renderer; } @@ -584,16 +585,16 @@ public class ResourceManager { } - public synchronized void setMapSource(ITileSource source){ + public synchronized void updateMapSource(boolean useVectorMap, ITileSource source){ log.info("Clear cache with new source " + cacheOfImages.size()); //$NON-NLS-1$ ArrayList list = new ArrayList(cacheOfImages.keySet()); - // remove first images (as we think they are older) for (int i = 0; i < list.size(); i ++) { Bitmap bmp = cacheOfImages.remove(list.get(i)); if(bmp != null){ bmp.recycle(); } } + renderer.clearCache(); if(source == null || source.getBitDensity() == 0){ maxImgCacheSize = 32; } else { @@ -681,15 +682,17 @@ public class ResourceManager { public final double leftLongitude; public final double rightLongitude; public final int zoom; + public final float rotate; public MapLoadRequest(double topLatitude, double leftLongitude, - double bottomLatitude, double rightLongitude, int zoom) { + double bottomLatitude, double rightLongitude, int zoom, float rotate) { super(); this.bottomLatitude = bottomLatitude; this.leftLongitude = leftLongitude; this.rightLongitude = rightLongitude; this.topLatitude = topLatitude; this.zoom = zoom; + this.rotate = rotate; } } @@ -732,7 +735,7 @@ public class ResourceManager { } else if(req instanceof MapLoadRequest){ if(!mapLoaded){ MapLoadRequest r = (MapLoadRequest) req; - renderer.loadMap(r.topLatitude, r.leftLongitude, r.bottomLatitude, r.rightLongitude, r.zoom); + renderer.loadMap(r.topLatitude, r.leftLongitude, r.bottomLatitude, r.rightLongitude, r.zoom, r.rotate); mapLoaded = true; } } diff --git a/OsmAnd/src/net/osmand/activities/MapActivity.java b/OsmAnd/src/net/osmand/activities/MapActivity.java index ab1be0ea66..65aa7683c0 100644 --- a/OsmAnd/src/net/osmand/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/activities/MapActivity.java @@ -241,7 +241,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso mapView.addLayer(contextMenuLayer, 9); // 10. route info layer routeInfoLayer = new RouteInfoLayer(routingHelper, (LinearLayout) findViewById(R.id.RouteLayout)); - mapView.addLayer(routeInfoLayer, 9); + mapView.addLayer(routeInfoLayer, 10); @@ -707,28 +707,31 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso trafficLayer.setVisible(OsmandSettings.isShowingYandexTraffic(this)); } - private void updateMapSource(ITileSource newSource){ + private void updateMapSource(){ + boolean vectorData = OsmandSettings.isUsingMapVectorData(this); + ITileSource newSource = OsmandSettings.getMapTileSource(this); if(mapView.getMap() instanceof SQLiteTileSource){ ((SQLiteTileSource)mapView.getMap()).closeDB(); } - ((OsmandApplication)getApplication()).getResourceManager().setMapSource(newSource); - mapView.setMap(newSource); + ((OsmandApplication)getApplication()).getResourceManager().updateMapSource(vectorData, newSource); + + mapView.setMap(vectorData ? null : newSource); + rendererLayer.setVisible(vectorData); } @Override protected void onResume() { super.onResume(); - // TODO not commit it - rendererLayer.setVisible(true); if(OsmandSettings.getMapOrientation(this) != getRequestedOrientation()){ setRequestedOrientation(OsmandSettings.getMapOrientation(this)); } currentScreenOrientation = getWindow().getWindowManager().getDefaultDisplay().getOrientation(); - ITileSource source = OsmandSettings.getMapTileSource(this); - if(!Algoritms.objectEquals(mapView.getMap(), source)){ - updateMapSource(source); + boolean showTiles = !OsmandSettings.isUsingMapVectorData(this); + ITileSource source = showTiles ? OsmandSettings.getMapTileSource(this) : null; + if (showTiles != !rendererLayer.isVisible() || !Algoritms.objectEquals(mapView.getMap(), source)) { + updateMapSource(); } updateApplicationModeSettings(); @@ -1280,17 +1283,27 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso } private void selectMapLayer(){ - Map entriesMap = SettingsActivity.getTileSourceEntries(); + Map entriesMap = SettingsActivity.getTileSourceEntries(this); Builder builder = new AlertDialog.Builder(this); final ArrayList keys = new ArrayList(entriesMap.keySet()); - builder.setItems(entriesMap.values().toArray(new String[entriesMap.size()]), new DialogInterface.OnClickListener(){ + String[] items = new String[entriesMap.size() + 1]; + items[0] = getString(R.string.vector_data); + int i = 1; + for(String it : entriesMap.values()){ + items[i++] = it; + } + builder.setItems(items, new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { Editor edit = OsmandSettings.getWriteableEditor(MapActivity.this); - edit.putString(OsmandSettings.MAP_TILE_SOURCES, keys.get(which)); + if(which == 0){ + edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, true); + } else { + edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, false); + edit.putString(OsmandSettings.MAP_TILE_SOURCES, keys.get(which - 1)); + } edit.commit(); - updateMapSource(OsmandSettings.getMapTileSource(MapActivity.this)); - mapView.refreshMap(); + updateMapSource(); } }); diff --git a/OsmAnd/src/net/osmand/activities/OsmandApplication.java b/OsmAnd/src/net/osmand/activities/OsmandApplication.java index 107aefa85f..c38c1bfe11 100644 --- a/OsmAnd/src/net/osmand/activities/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/activities/OsmandApplication.java @@ -45,6 +45,7 @@ public class OsmandApplication extends Application { public void onCreate(){ super.onCreate(); manager = new ResourceManager(this); + routingHelper = new RoutingHelper(OsmandSettings.getApplicationMode(OsmandApplication.this), OsmandApplication.this, player); uiHandler = new Handler(); startApplication(); } @@ -88,6 +89,7 @@ public class OsmandApplication extends Application { public String initCommandPlayer(){ if(player == null){ player = new CommandPlayer(OsmandApplication.this); + routingHelper.getVoiceRouter().setPlayer(player); } return player.init(); } @@ -111,7 +113,7 @@ public class OsmandApplication extends Application { warnings.add(w); } } - routingHelper = new RoutingHelper(OsmandSettings.getApplicationMode(OsmandApplication.this), OsmandApplication.this, player); + SavingTrackHelper helper = new SavingTrackHelper(OsmandApplication.this); if (helper.hasDataToSave()) { startDialog.startTask(getString(R.string.saving_gpx_tracks), -1); diff --git a/OsmAnd/src/net/osmand/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/activities/SettingsActivity.java index d5fdcae141..153228d340 100644 --- a/OsmAnd/src/net/osmand/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/activities/SettingsActivity.java @@ -1,6 +1,8 @@ package net.osmand.activities; import java.io.File; +import java.util.Arrays; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -43,6 +45,7 @@ import android.preference.Preference.OnPreferenceClickListener; import android.widget.Toast; public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener { + private final static String VECTOR_MAP = "#VECTOR_MAP"; //$NON-NLS-1$ private class BooleanPreference { private final boolean defValue; @@ -308,10 +311,12 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference maxLevelToDownload.setValue(OsmandSettings.getMaximumLevelToDownloadTile(this)+""); //$NON-NLS-1$ - Map entriesMap = getTileSourceEntries(); - entries = new String[entriesMap.size()]; - valueEntries = new String[entriesMap.size()]; - int ki = 0; + Map entriesMap = getTileSourceEntries(this); + entries = new String[entriesMap.size() + 1]; + valueEntries = new String[entriesMap.size() + 1]; + valueEntries[0] = VECTOR_MAP; + entries[0] = getString(R.string.vector_data); + int ki = 1; for(Map.Entry es : entriesMap.entrySet()){ entries[ki] = es.getValue(); valueEntries[ki] = es.getKey(); @@ -320,8 +325,10 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference tileSourcePreference.setEntries(entries); tileSourcePreference.setEntryValues(valueEntries); - tileSourcePreference.setValue(OsmandSettings.getMapTileSourceName(this)); - String mapName = " " +OsmandSettings.getMapTileSourceName(this); //$NON-NLS-1$ + String value = OsmandSettings.isUsingMapVectorData(this)? VECTOR_MAP : OsmandSettings.getMapTileSourceName(this); + String mapName = " " + (OsmandSettings.isUsingMapVectorData(this) ? getString(R.string.vector_data) : //$NON-NLS-1$ + OsmandSettings.getMapTileSourceName(this)); + tileSourcePreference.setValue(value); String summary = tileSourcePreference.getSummary().toString(); if (summary.lastIndexOf(':') != -1) { summary = summary.substring(0, summary.lastIndexOf(':') + 1); @@ -329,17 +336,31 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference tileSourcePreference.setSummary(summary + mapName); } - public static Map getTileSourceEntries(){ - + public static Map getTileSourceEntries(Context ctx){ Map map = new LinkedHashMap(); File dir = new File(Environment.getExternalStorageDirectory(), ResourceManager.TILES_PATH); if (dir != null && dir.canRead()) { - for (File f : dir.listFiles()) { - if (f.getName().endsWith(SQLiteTileSource.EXT)) { - String n = f.getName(); - map.put(f.getName(), n.substring(0, n.lastIndexOf('.'))); - } else if(f.isDirectory() && !f.getName().equals(ResourceManager.TEMP_SOURCE_TO_LOAD)){ - map.put(f.getName(), f.getName()); + File[] files = dir.listFiles(); + Arrays.sort(files, new Comparator(){ + @Override + public int compare(File object1, File object2) { + if(object1.lastModified() > object2.lastModified()){ + return -1; + } else if(object1.lastModified() == object2.lastModified()){ + return 0; + } + return 1; + } + + }); + if (files != null) { + for (File f : files) { + if (f.getName().endsWith(SQLiteTileSource.EXT)) { + String n = f.getName(); + map.put(f.getName(), n.substring(0, n.lastIndexOf('.'))); + } else if (f.isDirectory() && !f.getName().equals(ResourceManager.TEMP_SOURCE_TO_LOAD)) { + map.put(f.getName(), f.getName()); + } } } } @@ -440,13 +461,19 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference edit.commit(); ((OsmandApplication)getApplication()).initCommandPlayer(); } else if (preference == tileSourcePreference) { - edit.putString(OsmandSettings.MAP_TILE_SOURCES, (String) newValue); + if(VECTOR_MAP.equals((String) newValue)){ + edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, true); + } else { + edit.putString(OsmandSettings.MAP_TILE_SOURCES, (String) newValue); + edit.putBoolean(OsmandSettings.MAP_VECTOR_DATA, false); + } edit.commit(); String summary = tileSourcePreference.getSummary().toString(); if (summary.lastIndexOf(':') != -1) { summary = summary.substring(0, summary.lastIndexOf(':') + 1); - } - summary += " " + OsmandSettings.getMapTileSourceName(this); //$NON-NLS-1$ + } + summary += " " + (OsmandSettings.isUsingMapVectorData(this) ? getString(R.string.vector_data) : //$NON-NLS-1$ + OsmandSettings.getMapTileSourceName(this)); tileSourcePreference.setSummary(summary); } diff --git a/OsmAnd/src/net/osmand/render/RenderMapsRepositories.java b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java similarity index 63% rename from OsmAnd/src/net/osmand/render/RenderMapsRepositories.java rename to OsmAnd/src/net/osmand/render/MapRenderRepositories.java index b7d1dc09f3..23be58e204 100644 --- a/OsmAnd/src/net/osmand/render/RenderMapsRepositories.java +++ b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java @@ -20,9 +20,9 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.RectF; -public class RenderMapsRepositories { +public class MapRenderRepositories { - private final static Log log = LogUtil.getLog(RenderMapsRepositories.class); + private final static Log log = LogUtil.getLog(MapRenderRepositories.class); private final Context context; private Connection conn; private PreparedStatement pStatement; @@ -42,7 +42,7 @@ public class RenderMapsRepositories { - public RenderMapsRepositories(Context context){ + public MapRenderRepositories(Context context){ this.context = context; this.renderer = new OsmandRenderer(context); } @@ -54,7 +54,6 @@ public class RenderMapsRepositories { public boolean initializeNewResource(final IProgress progress, File file) { long start = System.currentTimeMillis(); try { - // TODO should support multiple db if (conn != null) { // close previous db conn.close(); @@ -117,10 +116,20 @@ public class RenderMapsRepositories { /** * @return true if no need to reevaluate map */ - public boolean updateMapIsNotNeeded(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom){ + public boolean updateMapIsNotNeeded(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, float rotate){ if (conn == null) { return true; } + boolean inside = insideBox(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom); + if(rotate < 0){ + rotate += 360; + } + + return inside && Math.abs(rotate - cRotate) < 30; + + } + + private boolean insideBox(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom) { boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude && cBottomLatitude <= bottomLatitude && cZoom == zoom; return inside; @@ -134,53 +143,60 @@ public class RenderMapsRepositories { " WHERE ? < maxLat AND ? > minLat AND maxLon > ? AND minLon < ?)"; //$NON-NLS-1$ - public synchronized void loadMap(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom) { - cBottomLatitude = bottomLatitude - (topLatitude - bottomLatitude) / 2; - cTopLatitude = topLatitude + (topLatitude - bottomLatitude) / 2; - cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude); - cRightLongitude = rightLongitude + (rightLongitude - leftLongitude); - cZoom = zoom; - - - log.info(String.format( - "BLat=%s, TLat=%s, LLong=%s, RLong=%s, zoom=%s", cBottomLatitude, cTopLatitude, cLeftLongitude, cRightLongitude, cZoom)); //$NON-NLS-1$ - - long now = System.currentTimeMillis(); - - if(pStatement == null){ - return; - } - try { - pStatement.setDouble(1, cBottomLatitude); - pStatement.setDouble(2, cTopLatitude); - pStatement.setDouble(3, cLeftLongitude); - pStatement.setDouble(4, cRightLongitude); - ResultSet result = pStatement.executeQuery(); - - List local = new LinkedList(); - try { - int count = 0; - while (result.next()) { - long id = result.getLong(1); - MapRenderObject obj = new MapRenderObject(id); - obj.setData(result.getBytes(2)); - obj.setName(result.getString(3)); - obj.setType(result.getInt(4)); - count++; - local.add(obj); - } + public synchronized void loadMap(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, float rotate) { + boolean inside = insideBox(topLatitude, leftLongitude, bottomLatitude, rightLongitude, zoom); + cRotate = rotate < 0 ? rotate + 360 : rotate; + if (!inside) { + cBottomLatitude = bottomLatitude - (topLatitude - bottomLatitude) / 2; + cTopLatitude = topLatitude + (topLatitude - bottomLatitude) / 2; + cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude); + cRightLongitude = rightLongitude + (rightLongitude - leftLongitude); + cZoom = zoom; - cObjects = local; - log.info(String.format("Search has been done in %s ms. %s results were found.", System.currentTimeMillis() - now, count)); //$NON-NLS-1$ - } finally { - result.close(); + log + .info(String + .format( + "BLat=%s, TLat=%s, LLong=%s, RLong=%s, zoom=%s", cBottomLatitude, cTopLatitude, cLeftLongitude, cRightLongitude, cZoom)); //$NON-NLS-1$ + + long now = System.currentTimeMillis(); + + if (pStatement == null) { + return; + } + try { + pStatement.setDouble(1, cBottomLatitude); + pStatement.setDouble(2, cTopLatitude); + pStatement.setDouble(3, cLeftLongitude); + pStatement.setDouble(4, cRightLongitude); + ResultSet result = pStatement.executeQuery(); + + List local = new LinkedList(); + try { + int count = 0; + while (result.next()) { + long id = result.getLong(1); + MapRenderObject obj = new MapRenderObject(id); + obj.setData(result.getBytes(2)); + obj.setName(result.getString(3)); + obj.setType(result.getInt(4)); + count++; + local.add(obj); + } + + cObjects = local; + log.info(String + .format("Search has been done in %s ms. %s results were found.", System.currentTimeMillis() - now, count)); //$NON-NLS-1$ + } finally { + result.close(); + } + } catch (java.sql.SQLException e) { + log.debug("Search failed", e); //$NON-NLS-1$ } - } catch (java.sql.SQLException e) { - log.debug("Search failed", e); //$NON-NLS-1$ } + // create new instance to distinguish that cache was changed RectF newLoc = new RectF((float)cLeftLongitude, (float)cTopLatitude, (float)cRightLongitude, (float)cBottomLatitude); - Bitmap bmp = renderer.generateNewBitmap(newLoc, cObjects, cZoom, 0); + Bitmap bmp = renderer.generateNewBitmap(newLoc, cObjects, cZoom, cRotate); Bitmap oldBmp = this.bmp; this.bmp = bmp; cachedWaysLoc = newLoc; @@ -198,10 +214,12 @@ public class RenderMapsRepositories { public synchronized void clearCache() { cObjects.clear(); + cBottomLatitude = cLeftLongitude = cRightLongitude = cTopLatitude = cRotate = cZoom = 0; if(bmp != null){ bmp.recycle(); bmp = null; } + cachedWaysLoc = new RectF(); } } diff --git a/OsmAnd/src/net/osmand/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/render/OsmandRenderer.java index 9e59b1a105..8616a82c7d 100644 --- a/OsmAnd/src/net/osmand/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/render/OsmandRenderer.java @@ -27,6 +27,7 @@ import android.graphics.Bitmap.Config; import android.graphics.Paint.Align; import android.graphics.Paint.Join; import android.graphics.Paint.Style; +import android.util.FloatMath; public class OsmandRenderer implements Comparator { private static final Log log = LogUtil.getLog(OsmandRenderer.class); @@ -39,7 +40,6 @@ public class OsmandRenderer implements Comparator { /// Colors private int clFillScreen = Color.rgb(241, 238, 232); - private int clPoint = Color.rgb(200, 200, 200); private int clTrunkRoad = Color.rgb(128,155,192); private int clMotorwayRoad = Color.rgb(168, 218, 168); private int clPrimaryRoad = Color.rgb(235, 152, 154); @@ -106,6 +106,7 @@ public class OsmandRenderer implements Comparator { bmp = Bitmap.createBitmap((int) ((rightX - leftX) * 256), (int) ((bottomY - topY) * 256), Config.RGB_565); Canvas cv = new Canvas(bmp); cv.drawRect(0, 0, bmp.getWidth(), bmp.getHeight(), paintFillWhite); + cv.rotate(-rotate); for (MapRenderObject w : objects) { draw(w, cv, leftX, topY, zoom, rotate); } @@ -122,23 +123,43 @@ public class OsmandRenderer implements Comparator { if(MapRenderingTypes.isHighway(obj.getType())){ drawHighway(obj, canvas, leftTileX, topTileY, zoom, rotate); } else { - + // TODO } } else { - PointF center = drawPolygon(obj, canvas, leftTileX, topTileY, zoom); + PointF center = drawPolygon(obj, canvas, leftTileX, topTileY, zoom, rotate); if(center != null){ int typeT = MapRenderingTypes.getPolygonPointType(obj.getType()); int subT = MapRenderingTypes.getPolygonPointSubType(obj.getType()); if(typeT > 0 && subT > 0){ - drawPointBitmap(canvas, zoom, center.x, center.y, typeT, subT); + drawPointBitmap(canvas, center.x, center.y, typeT, subT, zoom); } } } } + + public float calcDiffPixelY(float dTileX, float dTileY, float rotate){ + float rad = (float) Math.toRadians(rotate); + return (FloatMath.sin(rad) * dTileX + FloatMath.cos(rad) * dTileY) * 256f ; + } + + public float calcDiffPixelX(float dTileX, float dTileY, float rotate){ + float rad = (float) Math.toRadians(rotate); + return (FloatMath.cos(rad) * dTileX - FloatMath.sin(rad) * dTileY) * 256f ; + } + + // suppose that render works in one thread! Otherwise should be done anyway + private PointF TEMP_POINT = new PointF(); + private PointF calcPoint(double leftTileX, double topTileY, float latitude, float longitude, int zoom, float rotate){ + float dTileX = (float) (MapUtils.getTileNumberX(zoom, longitude) - leftTileX); + float dTileY = (float) (MapUtils.getTileNumberY(zoom, latitude) - topTileY); + TEMP_POINT.set(calcDiffPixelX(dTileX, dTileY, rotate), calcDiffPixelY(dTileX, dTileY, rotate)); + return TEMP_POINT; + } + - private PointF drawPolygon(MapRenderObject obj, Canvas canvas, double leftTileX, double topTileY, int zoom) { + private PointF drawPolygon(MapRenderObject obj, Canvas canvas, double leftTileX, double topTileY, int zoom, float rotate) { Paint paint = paintFill; float xText = 0; float yText = 0; @@ -192,15 +213,16 @@ public class OsmandRenderer implements Comparator { paint.setColor(color); for (int i = 0; i < obj.getPointsLength(); i++) { - float x = (float) ((MapUtils.getTileNumberX(zoom, obj.getPointLongitude(i)) - leftTileX) * 256f); - float y = (float) ((MapUtils.getTileNumberY(zoom, obj.getPointLatitude(i)) - topTileY) * 256f); - xText += x; - yText += y; + float lon = obj.getPointLongitude(i); + float lat = obj.getPointLatitude(i); + PointF p = calcPoint(leftTileX, topTileY, lat, lon, zoom, rotate); + xText += p.x; + yText += p.y; if (path == null) { path = new Path(); - path.moveTo(x, y); + path.moveTo(p.x, p.y); } else { - path.lineTo(x, y); + path.lineTo(p.x, p.y); } } @@ -211,12 +233,10 @@ public class OsmandRenderer implements Comparator { String name = obj.getName(); if(name != null){ - boolean accept = true; - if(zoom <= 15){ + boolean accept = zoom > 17; + if(zoom > 15){ accept = name.length() < 4; - } else if(zoom < 17){ - accept = name.length() < 6; - } else if(zoom < 18){ + } else if(zoom > 16){ accept = name.length() < 8; } if(accept){ @@ -230,129 +250,29 @@ public class OsmandRenderer implements Comparator { private void drawPoint(MapRenderObject obj, Canvas canvas, double leftTileX, double topTileY, int zoom, float rotate){ if (zoom > 15) { - float x = (float) ((MapUtils.getTileNumberX(zoom, obj.getPointLongitude(0)) - leftTileX) * 256f); - float y = (float) ((MapUtils.getTileNumberY(zoom, obj.getPointLatitude(0)) - topTileY) * 256f); + float lon = obj.getPointLongitude(0); + float lat = obj.getPointLatitude(0); + PointF p = calcPoint(leftTileX, topTileY, lat, lon, zoom, rotate); int subType = MapRenderingTypes.getPointSubType(obj.getType()); int type = MapRenderingTypes.getObjectType(obj.getType()); - drawPointBitmap(canvas, zoom, x, y, type, subType); + drawPointBitmap(canvas, p.x, p.y, type, subType, zoom); } } - - - private void drawPointBitmap(Canvas canvas, int zoom, float x, float y, int type, int subType) { - int resId = 0; - if(type == MapRenderingTypes.HIGHWAY){ - if (zoom > 16) { - if(subType == 38){ - resId = R.drawable.h_traffic_light; - } - } - } else if(type == MapRenderingTypes.AMENITY_OTHER){ - if (zoom > 16) { - switch (subType) { - case 10: - resId = R.drawable.h_police; - break; - case 18: - resId = R.drawable.h_toilets; - break; - case 11: - resId = R.drawable.h_postbox; - break; - case 12: - resId = R.drawable.h_postoffice; - break; - } - } - } else if(type == MapRenderingTypes.SHOP){ - if (zoom > 15) { - switch (subType) { - case 27: - case 65: - case 53: - resId = R.drawable.h_shop_supermarket; - break; - } - } - if (zoom > 16) { - switch (subType) { - case 31: - resId = R.drawable.h_shop_hairdresser; - break; - case 48: - resId = R.drawable.h_shop_butcher; - break; - case 42: - resId = R.drawable.h_shop_bakery; - break; - case 20: - resId = R.drawable.h_shop_diy; - break; - case 16: - resId = R.drawable.h_shop_convenience; - break; - case 13: - resId = R.drawable.h_shop_clothes; - break; - } - } - } else if(type == MapRenderingTypes.AMENITY_SUSTENANCE){ - // done - if (zoom > 15) { - switch (subType) { - case 1: - resId = R.drawable.h_restaurant; - break; - case 2: - resId = R.drawable.h_cafe; - break; - case 4: - resId = R.drawable.h_fast_food; - break; - case 5: - case 6: - case 7: - resId = R.drawable.h_bar; - break; - case 8: - resId = R.drawable.h_food_drinkingtap; - break; - } - } - } else if(type == MapRenderingTypes.AMENITY_FINANCE){ - if (zoom > 16){ - if(subType == 1){ - resId = R.drawable.h_atm; - } else if(subType == 2){ - resId = R.drawable.h_bank; - } - } - } else if(type == MapRenderingTypes.AMENITY_TRANSPORTATION){ - if (zoom >= 15){ - if(subType == 1 || subType == 2){ - resId = R.drawable.h_parking; - } else if(subType == 4){ - resId = R.drawable.h_fuel; - } else if(subType == 18){ - resId = R.drawable.h_bus_station; - } - } - } - + + + private void drawPointBitmap(Canvas canvas, float x, float y, int type, int subType, int zoom) { + int resId = getPointBitmap(zoom, type, subType); if(resId == 0){ // paintFill.setColor(clPoint); // canvas.drawCircle(x, y, 6, paintFill); } else { - drawBitmap(canvas, x, y, resId); - } - } - - private void drawBitmap(Canvas canvas, float x, float y, int resId) { - Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), resId); - if (bmp != null) { - canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintText); + Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), resId); + if (bmp != null) { + canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintText); + } } + } private void drawHighway(MapRenderObject obj, Canvas canvas, double leftTileX, double topTileY, int zoom, float rotate) { @@ -360,9 +280,6 @@ public class OsmandRenderer implements Comparator { return; } - float xText = 0; - float yText = 0; - Path path = null; float pathRotate = 0; float xLength = 0; @@ -422,74 +339,197 @@ public class OsmandRenderer implements Comparator { float yPrev = 0; int middle = obj.getPointsLength() / 2; for (int i = 0; i < obj.getPointsLength(); i++) { - float x = (float) ((MapUtils.getTileNumberX(zoom, obj.getPointLongitude(i)) - leftTileX) * 256f); - float y = (float) ((MapUtils.getTileNumberY(zoom, obj.getPointLatitude(i)) - topTileY) * 256f); -// xText += x; -// yText += y; + float lon = obj.getPointLongitude(i); + float lat = obj.getPointLatitude(i); + PointF p = calcPoint(leftTileX, topTileY, lat, lon, zoom, rotate); if (path == null) { path = new Path(); - path.moveTo(x, y); + path.moveTo(p.x, p.y); } else { - if (xPrev > 0) { - xLength += x - xPrev; // not abs - yLength += y - yPrev; // not abs - } + xLength += p.x - xPrev; // not abs + yLength += p.y - yPrev; // not abs if(i == middle){ - double rot = -Math.atan2(x - xPrev, y - yPrev) * 180 / Math.PI + 90; + double rot = - Math.atan2(p.x - xPrev, p.y - yPrev) * 180 / Math.PI; if (rot < 0) { rot += 360; } - if (rot < 270 && rot > 90) { + if (rot < 180) { rot += 180; inverse = true; } pathRotate = (float) rot; - xText = (x + xPrev) / 2; - yText = (y + yPrev) / 2; } if (pathRotate == 0) { } - path.lineTo(x, y); + path.lineTo(p.x, p.y); } - xPrev = x; - yPrev = y; + xPrev = p.x; + yPrev = p.y; } if (path != null) { -// xText /= obj.getPointsLength(); -// yText /= obj.getPointsLength(); canvas.drawPath(path, paint); if (obj.getName() != null && carRoad) { if (paintText.measureText(obj.getName()) < Math.max(Math.abs(xLength), Math.abs(yLength))) { - -// paintText.setTextSize(paintText.getTextSize() + 2); -// int sv = canvas.save(); -// canvas.rotate(pathRotate, xText, yText); -// canvas.drawText(obj.getName(), xText, yText, paintText); -// canvas.restoreToCount(sv); if (inverse) { path.rewind(); boolean st = true; for (int i = obj.getPointsLength() - 1; i >= 0; i--) { - float x = (float) ((MapUtils.getTileNumberX(zoom, obj.getPointLongitude(i)) - leftTileX) * 256f); - float y = (float) ((MapUtils.getTileNumberY(zoom, obj.getPointLatitude(i)) - topTileY) * 256f); + float lon = obj.getPointLongitude(i); + float lat = obj.getPointLatitude(i); + PointF p = calcPoint(leftTileX, topTileY, lat, lon, zoom, rotate); if (st) { st = false; - path.moveTo(x, y); + path.moveTo(p.x, p.y); } else { - path.lineTo(x, y); + path.lineTo(p.x, p.y); } } } canvas.drawTextOnPath(obj.getName(), path, 0, 0, paintText); -// paintText.setTextSize(paintText.getTextSize() - 2); } } } } - + + + public static int getPointBitmap(int zoom, int type, int subType) { + int resId = 0; + if(type == MapRenderingTypes.HIGHWAY){ + if (zoom > 16) { + if(subType == 38){ + resId = R.drawable.h_traffic_light; + } else if(subType == 40){ + resId = R.drawable.h_bus_stop; + } + } + + } else if(type == MapRenderingTypes.SHOP){ + if (zoom > 15) { + switch (subType) { + case 27: + case 65: + case 53: + resId = R.drawable.h_shop_supermarket; + break; + case 13: + resId = R.drawable.h_shop_clothes; + break; + case 31: + resId = R.drawable.h_shop_hairdresser; + break; + } + } + if (zoom > 16) { + switch (subType) { + case 48: + resId = R.drawable.h_shop_butcher; + break; + case 42: + resId = R.drawable.h_shop_bakery; + break; + case 20: + resId = R.drawable.h_shop_diy; + break; + case 16: + resId = R.drawable.h_shop_convenience; + break; + + + } + } + } else if(type == MapRenderingTypes.AMENITY_SUSTENANCE){ + if (zoom > 15) { + switch (subType) { + case 1: + resId = R.drawable.h_restaurant; + break; + case 2: + resId = R.drawable.h_cafe; + break; + case 4: + resId = R.drawable.h_fast_food; + break; + case 5: + resId = R.drawable.h_pub; + break; + case 7: + case 6: + resId = R.drawable.h_bar; + break; + case 8: + resId = R.drawable.h_food_drinkingtap; + break; + } + } + } else if(type == MapRenderingTypes.AMENITY_EDUCATION){ + if (zoom > 15){ + if(subType == 2){ + resId = R.drawable.h_school; + } else if(subType == 4){ + resId = R.drawable.h_library; + } + } + } else if (type == MapRenderingTypes.AMENITY_TRANSPORTATION) { + if (subType == 1 || subType == 2) { + resId = R.drawable.h_parking; + } else if (subType == 4) { + resId = R.drawable.h_fuel; + } else if (subType == 18) { + resId = R.drawable.h_bus_station; + } + } else if (type == MapRenderingTypes.AMENITY_FINANCE) { + if (subType == 1) { + if (zoom > 16) { + resId = R.drawable.h_atm; + } + } else if (subType == 2) { + if (zoom > 15) { + resId = R.drawable.h_bank; + } + } + } else if (type == MapRenderingTypes.AMENITY_HEALTHCARE) { + if (subType == 1) { + if (zoom > 15) { + resId = R.drawable.h_pharmacy; + } + } else if (subType == 2) { + resId = R.drawable.h_hospital; + } + } else if(type == MapRenderingTypes.AMENITY_OTHER){ + if (zoom > 16) { + switch (subType) { + case 10: + resId = R.drawable.h_police; + break; + case 18: + resId = R.drawable.h_toilets; + break; + case 15: + resId = R.drawable.h_recycling; + break; + case 7: + resId = R.drawable.h_embassy; + break; + case 8: + resId = R.drawable.h_grave_yard; + break; + case 17: + resId = R.drawable.h_telephone; + break; + case 11: + resId = R.drawable.h_postbox; + break; + case 12: + resId = R.drawable.h_postoffice; + break; + } + } + } + return resId; + } } diff --git a/OsmAnd/src/net/osmand/render/RendererLayer.java b/OsmAnd/src/net/osmand/render/RendererLayer.java index 1f36372ec2..24c8185aee 100644 --- a/OsmAnd/src/net/osmand/render/RendererLayer.java +++ b/OsmAnd/src/net/osmand/render/RendererLayer.java @@ -50,8 +50,8 @@ public class RendererLayer implements OsmandMapLayer { double leftLongitude = MapUtils.getLongitudeFromTile(view.getFloatZoom(), tileRect.left); double bottomLatitude = MapUtils.getLatitudeFromTile(view.getFloatZoom(), tileRect.bottom); double rightLongitude = MapUtils.getLongitudeFromTile(view.getFloatZoom(), tileRect.right); - resourceManager.updateRendererIfNeeded(topLatitude, leftLongitude, bottomLatitude, rightLongitude, view.getZoom()); - RenderMapsRepositories renderer = resourceManager.getRenderer(); + resourceManager.updateRendererIfNeeded(topLatitude, leftLongitude, bottomLatitude, rightLongitude, view.getZoom(), view.getRotate()); + MapRenderRepositories renderer = resourceManager.getRenderer(); if (renderer != null && renderer.getBitmap() != null) { RectF newLoc = renderer.getCachedWaysLoc(); double leftX1 = MapUtils.getTileNumberX(view.getFloatZoom(), newLoc.left); @@ -73,7 +73,6 @@ public class RendererLayer implements OsmandMapLayer { public void setVisible(boolean visible) { this.visible = visible; - view.setShowMapTiles(!visible); view.refreshMap(); } diff --git a/OsmAnd/src/net/osmand/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/views/OsmandMapTileView.java index 053c4cca57..ea269d74d7 100644 --- a/OsmAnd/src/net/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/views/OsmandMapTileView.java @@ -83,8 +83,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall // name of source map private ITileSource map = null; - private boolean showMapTiles = true; - private IMapLocationListener locationListener; private OnLongClickListener onLongClickListener; @@ -244,7 +242,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall public void setZoom(float zoom){ - if (map == null || ((map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { + if ((map == null && zoom < 22) || + ((map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { animatedDraggingThread.stopAnimating(); this.zoom = zoom; refreshMap(); @@ -254,7 +253,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall // for internal usage @Override public void zoomTo(float zoom, boolean notify) { - if (map == null || ((map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { + if ((map == null && zoom < 22) || + ((map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { this.zoom = zoom; refreshMap(); if(notify && locationListener != null){ @@ -291,10 +291,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall public void setMap(ITileSource map) { this.map = map; - if(map.getMaximumZoomSupported() + OVERZOOM_IN < this.zoom){ + if(map !=null && map.getMaximumZoomSupported() + OVERZOOM_IN < this.zoom){ zoom = map.getMaximumZoomSupported() + OVERZOOM_IN; } - if(map.getMinimumZoomSupported() > this.zoom){ + if(map !=null && map.getMinimumZoomSupported() > this.zoom){ zoom = map.getMinimumZoomSupported(); } refreshMap(); @@ -449,10 +449,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall if (canvas != null) { canvas.save(); boundsRect.set(0, 0, getWidth(), getHeight()); - canvas.drawRect(boundsRect, paintWhiteFill); canvas.rotate(rotate, w , h); try { - if (showMapTiles) { + if (map != null) { ResourceManager mgr = getApplication().getResourceManager(); boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getContext()) && map.couldBeDownloadedFromInternet(); @@ -507,7 +506,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall } else { int xZoom = ((left + i) % div) * tileSize / div; int yZoom = ((top + j) % div) * tileSize / div; - ; bitmapToZoom.set(xZoom, yZoom, xZoom + tileSize / div, yZoom + tileSize / div); bitmapToDraw.set(x1, y1, x1 + ftileSize, y1 + ftileSize); canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap); @@ -519,6 +517,19 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall } } } + } else { + calculateTileRectangle(boundsRect, w, h, tileX, tileY, tilesRect); + int left = (int) FloatMath.floor(tilesRect.left); + int top = (int) FloatMath.floor(tilesRect.top); + int width = (int) (FloatMath.ceil(tilesRect.right) - left); + int height = (int) (FloatMath.ceil(tilesRect.bottom) - top); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + float x1 = (i + left - tileX) * ftileSize + w; + float y1 = (j + top - tileY) * ftileSize + h; + drawEmptyTile(canvas, x1, y1, ftileSize); + } + } } drawOverMap(canvas); } finally { @@ -586,22 +597,21 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall canvas.rotate(rotate, w , h); try { - if (showMapTiles) { + Bitmap bmp = null; + if (map != null) { ResourceManager mgr = getApplication().getResourceManager(); - Bitmap bmp = mgr.getTileImageForMapSync(null, map, request.xTile, request.yTile, request.zoom, false); - float x = (request.xTile - tileX) * getTileSize() + w; - float y = (request.yTile - tileY) * getTileSize() + h; - float tileSize = getTileSize(); - if (bmp == null) { - drawEmptyTile(canvas, x, y, tileSize); - } else { - bitmapToZoom.set(0, 0, getSourceTileSize(), getSourceTileSize()); - bitmapToDraw.set(x, y, x + tileSize, y + tileSize); - canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap); - } + bmp = mgr.getTileImageForMapSync(null, map, request.xTile, request.yTile, request.zoom, false); + } + + float x = (request.xTile - tileX) * getTileSize() + w; + float y = (request.yTile - tileY) * getTileSize() + h; + float tileSize = getTileSize(); + if (bmp == null) { + drawEmptyTile(canvas, x, y, tileSize); } else { - boundsRect.set(0, 0, getWidth(), getHeight()); - canvas.drawRect(boundsRect, paintWhiteFill); + bitmapToZoom.set(0, 0, getSourceTileSize(), getSourceTileSize()); + bitmapToDraw.set(x, y, x + tileSize, y + tileSize); + canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap); } drawOverMap(canvas); } finally { @@ -640,7 +650,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall */ public int getMapXForPoint(double longitude){ double tileX = MapUtils.getTileNumberX(zoom, longitude); - return (int) ((tileX - getXTile()) * getTileSize()+ getCenterPointX()); + return (int) ((tileX - getXTile()) * getTileSize() + getCenterPointX()); } public int getMapYForPoint(double latitude){ double tileY = MapUtils.getTileNumberY(zoom, latitude); @@ -758,13 +768,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall zoomPositionChanged(getFloatZoom()); } - public void setShowMapTiles(boolean visible){ - this.showMapTiles = visible; - } - - public boolean isShowMapTiles() { - return showMapTiles; - } @Override