樹心幽徑

20200131用JavaScript將文字盒中的大地座標轉為 kml 或 gpx 航跡檔
2020/01/31,19:50

 

(1)JS網頁程式碼:js2kmlgpx.txt下載 (5 KB) | created 01 二月, 2020

js2kmlgpx.txt檔案下載後將txt副檔名改為htm副檔名即可用firefox瀏覽器開啟並使用之。

 

(2 )產生KML航跡檔文字的執行結果並提供kml檔下載,可選用GOOGLE-EARTH開啟。

alt

 

(3 )產生GPX航跡檔文字的執行結果並提供gpx檔下載,可選用MapSource或BaseCamp開啟。

alt

 

REF: 20200124安裝魯地圖、MapSource、BaseCamp、GoogleEarth並用LIBRE-OFFICE 的CALC試算表及notepad記事本來製作伊加之蕃的kml及gpx航跡檔

20200124安裝魯地圖、MapSource、BaseCamp、GoogleEarth並用LIBRE-OFFICE 的CALC試算表及notepad記事本來製作伊加之蕃的kml及gpx航跡檔
2020/01/24,17:16

 

 

(1)在 魯地圖 Taiwan TOPO 下載Install_MOI_Taiwan_TOPO_camp.exe(186MB)

[mirror Rex] / [mirror KCWu] / [mirror Happyman]並安裝Taiwan TOPO 魯地圖

(2a)下載並安裝MapSource 6.16.3更新程式(要先裝有GARMIN 定位器附的MAPSOURCE)

(2b)執行MapSource並按CTRL+U選用(1)所裝的Taiwan TOPO 魯地圖

(3a)使用MapSource的航點標定功能自行標定一序列想要去的航點路線(例如下二圖,編輯功能表/偏好設定分別為WGS84及TWD67)並複製取得自訂航點的WGS84大地座標及TWD67大地座標。

alt

 

alt

 

(3b)用LIBRE-OFFICE 的CALC製作如下試算表,詳如20200127_0208eplus.ods下載 (51 KB)

如下NAME,twd67,wgs84三欄為取自(3a)所標定的航點資料。

如下x67欄D2的公式為=MID(B2,1,6) 

如下y67欄E2的公式為=MID(B2,8,7)

如下x97欄 F2的公式為= D2 + 807.8 + 0.00001549 * D2 + 0.000006521 *E2

如下y97欄 G2的公式為 =E2 - 248.6 + 0.00001549 * E2 + 0.000006521 *D2

如下lon欄h2的公式為=MID(C2,2,8)

如下lat欄i2的公式為=MID(C2,12,9)

如下gpxWPT欄J2的公式為 ="<wpt lon='" & I2 & "' lat='" & H2 & "'> <name>" & A2 & "</name>  </wpt>"

如下gpxTrkpt欄k2的公式為 ="<trkpt lat='" & H2 &"' lon='" & I2 & "'> <ele>1800</ele>  </trkpt>"

如下kmlWPT欄L2的公式為  ="<Placemark><name>" & A2 &"</name><Point><coordinates>" & I2 & "," & H2 & "</coordinates></Point></Placemark>"

如下kmlTrkpt欄M2的公式為 =I2 & "," & H2

 

(3c)20200127_0208eplus.ods 試算表的內容欄位如下:

A1

NAME

B1

TDW67

C1

WGS84

D1

X67

E1

Y67

F1

X97

G1

Y97

H1

lon

I1

lat

J1

gpxWPT

K1

gpxTrkpt

L1

kmlWPT

M1

KMLTrkpt

e00 244925 2560594 N23.14545 E120.95866 244925 2560594 245,753 2560387 23.14545 120.95866 <wpt lon='120.95866' lat='23.14545'> <name>e00</name> </wpt> <trkpt lat='23.14545' lon='120.95866'> <ele>1800</ele> </trkpt> <Placemark><name>e00</name><Point><coordinates>120.95866,23.14545</coordinates></Point></Placemark> 120.95866,23.14545
e01 244760 2560524 N23.14482 E120.95705 244760 2560524 245,588 2560317 23.14482 120.95705 <wpt lon='120.95705' lat='23.14482'> <name>e01</name> </wpt> <trkpt lat='23.14482' lon='120.95705'> <ele>1800</ele> </trkpt> <Placemark><name>e01</name><Point><coordinates>120.95705,23.14482</coordinates></Point></Placemark> 120.95705,23.14482
e02 244621 2560461 N23.14425 E120.95569 244621 2560461 245,449 2560254 23.14425 120.95569 <wpt lon='120.95569' lat='23.14425'> <name>e02</name> </wpt> <trkpt lat='23.14425' lon='120.95569'> <ele>1800</ele> </trkpt> <Placemark><name>e02</name><Point><coordinates>120.95569,23.14425</coordinates></Point></Placemark> 120.95569,23.14425
e03 244466 2560429 N23.14396 E120.95418 244466 2560429 245,294 2560222 23.14396 120.95418 <wpt lon='120.95418' lat='23.14396'> <name>e03</name> </wpt> <trkpt lat='23.14396' lon='120.95418'> <ele>1800</ele> </trkpt> <Placemark><name>e03</name><Point><coordinates>120.95418,23.14396</coordinates></Point></Placemark> 120.95418,23.14396
e04 244333 2560310 N23.14288 E120.95288 244333 2560310 245,161 2560103 23.14288 120.95288 <wpt lon='120.95288' lat='23.14288'> <name>e04</name> </wpt> <trkpt lat='23.14288' lon='120.95288'> <ele>1800</ele> </trkpt> <Placemark><name>e04</name><Point><coordinates>120.95288,23.14288</coordinates></Point></Placemark> 120.95288,23.14288
e05 244135 2560205 N23.14194 E120.95095 244135 2560205 244,963 2559998 23.14194 120.95095 <wpt lon='120.95095' lat='23.14194'> <name>e05</name> </wpt> <trkpt lat='23.14194' lon='120.95095'> <ele>1800</ele> </trkpt> <Placemark><name>e05</name><Point><coordinates>120.95095,23.14194</coordinates></Point></Placemark> 120.95095,23.14194
e06 244073 2560130 N23.14126 E120.95035 244073 2560130 244,901 2559923 23.14126 120.95035 <wpt lon='120.95035' lat='23.14126'> <name>e06</name> </wpt> <trkpt lat='23.14126' lon='120.95035'> <ele>1800</ele> </trkpt> <Placemark><name>e06</name><Point><coordinates>120.95035,23.14126</coordinates></Point></Placemark> 120.95035,23.14126
e07 244046 2560017 N23.14024 E120.95008 244046 2560017 244,874 2559810 23.14024 120.95008 <wpt lon='120.95008' lat='23.14024'> <name>e07</name> </wpt> <trkpt lat='23.14024' lon='120.95008'> <ele>1800</ele> </trkpt> <Placemark><name>e07</name><Point><coordinates>120.95008,23.14024</coordinates></Point></Placemark> 120.95008,23.14024
e08 243952 2559698 N23.13736 E120.94916 243952 2559698 244,780 2559491 23.13736 120.94916 <wpt lon='120.94916' lat='23.13736'> <name>e08</name> </wpt> <trkpt lat='23.13736' lon='120.94916'> <ele>1800</ele> </trkpt> <Placemark><name>e08</name><Point><coordinates>120.94916,23.13736</coordinates></Point></Placemark> 120.94916,23.13736

 

(3d)TWD67及TWD97的座標互換公式如下:


x67=x97-807.8-0.00001549*x97-0.000006521*y97;



y67=y97+248.6-0.00001549*y97-0.000006521*x97;








x67 y67 x97 y97
Qilis 275034.084586792 2582984.79386616 275863 2582778






x97 = x67 + 807.8 + 0.00001549 * x67 + 0.000006521 * y67;



y97 = y67 - 248.6 + 0.00001549 * y67 + 0.000006521 * x67;







Qilis 275034.0846 2582984.79387 275,863 2582778

 

(4a)將如下gpxWPT及gpxTrkpt二個欄位的內容貼入如下gpx檔的適當位置中即可製作出如下的gpx檔:20200121伊蕃wptTrk3.gpx下載 (17 KB)

gpxWPT gpxTrkpt
<wpt lon='120.95866' lat='23.14545'> <name>e00</name> </wpt> <trkpt lat='23.14545' lon='120.95866'> <ele>1800</ele> </trkpt>
<wpt lon='120.95705' lat='23.14482'> <name>e01</name> </wpt> <trkpt lat='23.14482' lon='120.95705'> <ele>1800</ele> </trkpt>
<wpt lon='120.95569' lat='23.14425'> <name>e02</name> </wpt> <trkpt lat='23.14425' lon='120.95569'> <ele>1800</ele> </trkpt>

 (4b)20200121伊蕃wptTrk3.gpx內容摘述如下:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.15.7" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata>
    <link href="http://www.garmin.com">
      <text>Garmin International</text>
    </link>
    <time>2020-01-22T00:46:18Z</time>
    <bounds maxlat="23.1454495" maxlon="120.9586646" minlat="23.0881861" minlon="120.8897781"/>
</metadata>
<wpt lon='120.95866' lat='23.14545'> <name>e00</name>  </wpt>
<wpt lon='120.95705' lat='23.14482'> <name>e01</name>  </wpt>
<wpt lon='120.95569' lat='23.14425'> <name>e02</name>  </wpt>

:


<trk>
<name>20200127-0208gPLUS</name>
    <extensions>
      <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        <gpxx:DisplayColor>Green</gpxx:DisplayColor>
      </gpxx:TrackExtension>
    </extensions>
<trkseg>
<trkpt lat='23.16128' lon='120.92484'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16198' lon='120.92435'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16214' lon='120.92345'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16232' lon='120.92215'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16270' lon='120.91963'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16334' lon='120.91780'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16377' lon='120.91587'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16478' lon='120.91550'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16685' lon='120.91489'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16797' lon='120.91485'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.16946' lon='120.91400'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17115' lon='120.91195'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17135' lon='120.91100'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17210' lon='120.90991'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17422' lon='120.90997'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17521' lon='120.91003'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17697' lon='120.90937'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.17906' lon='120.90887'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.18001' lon='120.90908'> <ele>1800</ele>  </trkpt>
<trkpt lat='23.18072' lon='120.90938'> <ele>1800</ele>  </trkpt>
</trkseg>
</trk>
</gpx>

(4c)用MapSource 開啟(4a)所製成的20200121伊蕃wptTrk3.gpx(下載)成功。

 

(5a)將如下kmlWPT及kmlTrkpt二個欄位的內容貼入如下kml檔的適當位置中即可製作如下的kml檔: 20200127-0208eplus5.kml 下載 (15 KB)

kmlWPT KMLTrkpt
<Placemark><name>e00</name><Point><coordinates>120.95866,23.14545</coordinates></Point></Placemark> 120.95866,23.14545
<Placemark><name>e01</name><Point><coordinates>120.95705,23.14482</coordinates></Point></Placemark> 120.95705,23.14482
<Placemark><name>e02</name><Point><coordinates>120.95569,23.14425</coordinates></Point></Placemark>

120.95569,23.14425

(5b)  20200127-0208eplus5.kml內容摘述如下:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>GPS device</name>
<Style id="lineStyle">
<LineStyle>
<color>FF0000EF</color>
<width>3</width>
</LineStyle>
</Style>
<Folder>
<name>Waypoints</name>
<Placemark><name>e00</name><Point><coordinates>120.95866,23.14545</coordinates></Point></Placemark>
<Placemark><name>e01</name><Point><coordinates>120.95705,23.14482</coordinates></Point></Placemark>
<Placemark><name>e02</name><Point><coordinates>120.95569,23.14425</coordinates></Point></Placemark>
<Placemark><name>e03</name><Point><coordinates>120.95418,23.14396</coordinates></Point></Placemark>

:

:

<Placemark><name>g20</name><Point><coordinates>120.90938,23.18072</coordinates></Point></Placemark>

</Folder>


<Folder> <name>Tracks</name> <Folder> <snippet/> <description> <![CDATA[<table> <tr><td><b>Distance</b> 8.0 mi </td></tr> </table>]]> </description>
<Placemark> <name>20200122EPLUS </name>
<styleUrl>#lineStyle</styleUrl>
<LineString> <tessellate>1</tessellate>
<coordinates>
120.95866,23.14545
120.95705,23.14482
120.95569,23.14425
:

 120.94141,23.12871
120.93987,23.12681
120.93898,23.12482
120.93842,23.12279
:

 120.88978,23.10096
</coordinates>
</LineString>

<LineString> <tessellate>2</tessellate>
<coordinates>
120.93904,23.11520
120.93846,23.11436
120.93707,23.11286
:

 120.94065,23.08841

</coordinates>
</LineString>

<LineString> <tessellate>3</tessellate>
<coordinates>
120.92484,23.16128
120.92435,23.16198
:

 120.90887,23.17906
120.90908,23.18001
120.90938,23.18072
</coordinates>
</LineString>
</Placemark> </Folder> </Folder>
</Document> </kml>

(6a)下載並安裝google earth

(6b)用google earth 開啟(4a)所製成的20200121伊蕃wptTrk3.gpx(下載)成功。

(6c)用google earth 開啟(5a)所製成的20200127-0208eplus5.kml( 下載)成功。

http://oldwww.kmvs.km.edu.tw/lf/gallery/70/20200122EPLUS.jpg

 

(7a)下載並安裝BaseCamp(安裝完成重開機才會生效)。

2019/10/30

BaseCamp 4.7.1版軟體更新下載

Download下載軟體(61.58 MB)

(7b)執行BaseCamp並於地圖功能表中選用(1)所裝的Taiwan TOPO 魯地圖

(7c)用BaseCamp 開啟(4a)所製成的20200121伊蕃wptTrk3.gpx(下載)成功。

REF :

20200112設計第一個Android APP:自訂程式標題、文字物件與按鈕
2020/01/12,11:49

REF1  : https://readandplay.pixnet.net/blog/post/140001110

ref2 : 把APP安裝到手機裡

ref3:新增一個按鈕、加上點擊的事件

ref4:<Android> Button OnClickListener 事件三種做法

ref5:【APP/Android】onClick事件的5種實現方式

 

(1)下載Android Studio  App 開發工具(android-studio-ide-191.6010548-windows.exe)

https://developer.android.com/studio 3.5.3 for Windows 64-bit (718 MB)

(2)安裝完成並啟動IDE/下載各式組件(約573MB)「...COMPONENTS:SDK Tools、Patch Applier、emulator(262MB)、platform(75MB) 、build-tools(38MB)、Intel x86 Emulator Accelerator (HAXM installer)、sources(38MB)...」

:

Downloading https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip
Downloading https://dl.google.com/android/repository/3534162-studio.sdk-patcher.zip
Downloading https://dl.google.com/android/repository/emulator-windows-6110076.zip
Downloading https://dl.google.com/android/repository/platform-tools_r29.0.5-windows.zip
Downloading https://dl.google.com/android/repository/extras/intel/haxm-windows_v7_5_4.zip
Downloading https://dl.google.com/android/repository/platform-29_r04.zip
Downloading https://dl.google.com/android/repository/build-tools_r29.0.2-windows.zip
Downloading https://dl.google.com/android/repository/sources-29_r01.zip
Running Intel® HAXM installer
:

(3-1)「Start a new Android Studio project」:建立新專案/「Creates A New Empty Activity」

(3-2)輸入並設定如下內容:「name: TreeHeartFirst」/「Package name:com.example.treeheartfirst」/「Save Location:C:\Users\treehrt\AndroidStudioProjects\TreeHeartFirst」/「Langauage:java」/「Minimum API level : API 15」

(3-3)syncing :下載gradles distribution

(3-4)下載Kotlin plugins

(3-5)允許存取「OpenJDK Platform binary」

 

(4-1) 點選app/res/layout/下的「activity_main.xml」或「content_main.xml」並修改TextView物件預設的顯示文字.

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H黑熊問候大家好!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

(4-2) 點選「app/res/values/strings.xml」並修改app_name如下:

<string name="app_name">Treehrt5:TaiwanBlackBear台灣黑熊</string>
<string name="buttonText">BlackBear!黑熊來了</string>
<string name="buttonOnClickMessage">按了</string> 

(4-3) 點選app/res/layout/下的「content_main.xml」的TextView下加入如下文字:

<Button
 
    android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/buttonText"
   android:onClick="buttonOnClick
/>
(4-4)開啟app/java/[專案id]/MainActivity.java

void buttonOnClick(View view) {
Toast toast = Toast.makeText(this, R.string.buttonOnClickMessage, Toast.LENGTH_SHORT);
toast.show();
}

(5-1)新增ANDROID模擬器:「Open AVD Manger」/CreateVitualDevice/選「Phone: Pixel 3a」/選「Android 10.0」

(5-2)下載並安裝Google Play Intel x86 Atom System Image第8版 (system-images;android-29;google_apis_playstore;x86)API LEVEL: 29  約1.1GB

(5-3) AVD NAME: Pixel 3a API 29

(5-4)按下「Pixel 3a模擬器」旁的執行鈕即可出現執行結果。

alt

 

(6) 如果執行的APP一直卡在「Waiting for Target Device to Come Online」,進行如下操作即可解決:

AVD Manager---Right Click Emulator----Wipe Data----Run App Again


20200109自selldb資料庫的custs資料表選擇要刪除的資料錄來刪除的PHP程式(c3.php)
2020/01/09,09:53

(1)c3.php程式碼:

<body bgcolor=green>
<?php
function exeSQL($con,$sql){
if( $query= mysqli_query($con, $sql) ) {echo " $sql 成功!<br> "; }
else { echo " $sql Failure!<br> "; }     return $query;
}

function dumpTableForDel($table,$con,$bgcolor){
    $sql= "select * from $table";
    $query=exeSQL($con,$sql);
    echo "<table bgcolor=$bgcolor border=7>";
    echo "<tr bgcolor=cyan>";
    $fc= mysqli_num_fields($query) ;
    while ($field = mysqli_fetch_field($query)){
        printf("<td bgcolor=pink>%s", $field->name);
        }
    echo "<td>DEL";
    $rowc=0;
    while ($row = mysqli_fetch_array($query)){
        echo "<tr bgcolor=purple>";
        for ($i=0;$i<$fc;$i++){
            echo  "<td bgcolor=gray>" . $row[$i];
        }
echo "<td><a href=c3.php?id=" . $row[0] .">DEL</a>";
        $rowc++;
}
echo "</table>";
echo "total $rowc records <br><br>";
}
$con = mysqli_connect('127.0.0.1', 'root', 'w??????', 'selldb');
if (!$con) { echo "Error"; exit(); }
$sql = 'set names utf8;';
$query= exeSQL($con,$sql);
dumpTableForDel("custs",$con,"yellow");
$id=$_GET['id'];
if ($id<>NULL){
    $sql="delete from custs where id=$id";
    $query= exeSQL($con,$sql);
    echo "刪掉 id=$id 的資料錄後,custs資料表內容如下<br>";
    dumpTableForDel("custs",$con,"cyan");
}

mysqli_close ($con);
?>
</body>


(2)執行結果:

set names utf8; 成功!
select * from custs 成功!

id name amount tel DEL
10001 小狗 156 08-233375 DEL
10002 小貓 256 08-233375 DEL
10001 小草 1000 08-233375 DEL
10002 天牛 3000 03-933375 DEL
20002 天牛 3000 03-933375 DEL
30002 天牛 3000 03-933375 DEL

total 6 records

delete from custs where id=10001 OK!
刪掉 id=10001 的資料錄後,custs資料表內容如下
select * from custs 成功!

id name amount tel DEL
10002 小貓 256 08-233375 DEL
10002 天牛 3000 03-933375 DEL
20002 天牛 3000 03-933375 DEL
30002 天牛 3000 03-933375 DEL

total 4 records

 

20200108設計PHP函數dumpTable,用來列出selldb資料庫的custs資料表的全部資料錄
2020/01/08,09:26

(1) code : c2.php

<body bgcolor=lightblue>
<?php
function executeSQL($con,$sql){
    if( $query= mysqli_query($con, $sql) ){ echo " [$sql] OK!<br> "; }
    else { echo " [$sql] Failure!<br> "; }
    return $query;
}

function dumpTable($table,$con,$bgcolor){
    $sql= "select * from $table";
    $query= executeSQL($con,$sql);
    echo "<table bgcolor=$bgcolor border=3>";
    echo "<tr>";
    $fc= mysqli_num_fields($query) ;
    while ($field = mysqli_fetch_field($query)){
        printf("<td>%s", $field->name);
    }
    $rowc=0;
    while ($row = mysqli_fetch_array($query)){
        echo "<tr>";
        for ($i=0;$i<$fc;$i++){
            echo  "<td>" . $row[$i];
        }
        $rowc++;
    }
    echo "</table>";
    echo "total $rowc records<br><br>";
}

$con = @mysqli_connect('localhost', 'root', 'w?????', 'selldb');
if (!$con) { echo "Error: " . mysqli_connect_error(); exit(); }
$sql = 'set names utf8;';
 
$query= executeSQL($con,$sql);
dumpTable("custs",$con,"red");
dumpTable("custs",$con,"green");
dumpTable("custs",$con,"blue");
mysqli_close ($con);

?>
</body>

(2)執行結果

[set names utf8;] OK!
[select * from custs] OK!

id name amount tel
10001 小草 1000 08-233375
10002 天牛 3000 082-20488
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
total 11 records

[select * from custs] OK!
id name amount tel
10001 小草 1000 08-233375
10002 天牛 3000 082-20488
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
total 11 records

[select * from custs] OK!
id name amount tel
10001 小草 1000 08-233375
10002 天牛 3000 082-20488
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
10003 小吉 5000 24680
total 11 records
20200106用GIMP製作有透明背景的動物圖png檔並在HTML網頁中呈現。
2020/01/06,23:25

(1)製作如下背景透明的動物圖案並存在桌面為wild.png

(1-1)啟動GIMP/按CTRL+N/圖片尺寸寬600、高800/進階「填上/透明」。

(1-2)左上工具區選「鉛筆工具」

(1-3)左上工具區/「前景」挑「紫色」

(1-4)右上「筆刷」挑「最大的實心圓」

(1-5)用滑鼠在工作區繪出一隻紫色線的動物

(1-6)按CTRL+E將工作區匯出到桌面,檔名為wild.png。

 

(2-1)用記事本編寫如下「六行HTML文字」並存檔在桌面為wild.htm

(2-2)用firefox瀏覽wild.htm的結果如下:

alt

 

(3)參考「如下連結文章 http://gimpbasic.blogspot.com/2011/10/210.html 」,用多重選取區的加(SHIFT)減(CTRL)操作及圖樣填滿來產生如下太極圖。

alt

 

20200102用JavaScript設計二分搜尋法bs01.htm
2020/01/02,20:53

REF:20191122用DevC++來編寫循序搜尋法與二分搜尋法程式

 

(1-1)在notepad輸入如下JS程式碼並存檔在桌面為bs01.htm

<script>
var a = [1, 13, 5, 26, 7 , 18 , 9];
a.sort(function(a, b){return a - b;});
document.write("二分搜尋法<br>待搜尋陣列a[]="+a);

bsearch(1);
bsearch(4);
bsearch(18);
bsearch(26);


function bsearch(k){
    document.write("<hr>數字k="+k+"的搜尋結果如下:");
    var L=0;
    var R=a.length-1;
    var M=(L+R)/2;
    while (L<=R){
            document.write("<br> L="+L+" a[L]="+a[L]+", R="+R+" a[R]="+a[R]+", M="+M+" a[M]="+a[M]+"");
            if (a[M]==k) {
            document.write("<br> 找到一筆匹配在 M="+ M + " a[M]="+a[M]);
                break;
            }
            else{
                if (k >a[M]) {
                    L=M+1;
                document.write("<br> k="+k+" > a[M]="+a[M]+" 往大的那一半找 => L="+L+" R=" +R + "<br>");
                    }
                else {
                    R=M-1;
                    document.write("<br> k="+k+" < a[M]="+a[M]+" 往小的那一半找 =>  L="+L+" R=" +R + "<br>");
                    }
            }
            M=(L+R)/2;
        }
       if (L>R) document.write(" <br> 因"+L+"=L  >  R="+R+" => [L,R]的數字區間不存在,故找不到k="+k);
}

</script>

(2) 用firefox開啟bs01.htm,瀏覽結果如下:

二分搜尋法
待搜尋陣列a[]=1,5,7,9,13,18,26


數字k=1的搜尋結果如下:
L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9
k=1 < a[M]=9 往小的那一半找 => L=0 R=2

L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5
k=1 < a[M]=5 往小的那一半找 => L=0 R=0

L=0 a[L]=1, R=0 a[R]=1, M=0 a[M]=1
找到一筆匹配在 M=0 a[M]=1


數字k=4的搜尋結果如下:
L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9
k=4 < a[M]=9 往小的那一半找 => L=0 R=2

L=0 a[L]=1, R=2 a[R]=7, M=1 a[M]=5
k=4 < a[M]=5 往小的那一半找 => L=0 R=0

L=0 a[L]=1, R=0 a[R]=1, M=0 a[M]=1
k=4 > a[M]=1 往大的那一半找 => L=1 R=0

因1=L > R=0 => [L,R]的數字區間不存在,故找不到k=4


數字k=18的搜尋結果如下:
L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9
k=18 > a[M]=9 往大的那一半找 => L=4 R=6

L=4 a[L]=13, R=6 a[R]=26, M=5 a[M]=18
找到一筆匹配在 M=5 a[M]=18


數字k=26的搜尋結果如下:
L=0 a[L]=1, R=6 a[R]=26, M=3 a[M]=9
k=26 > a[M]=9 往大的那一半找 => L=4 R=6

L=4 a[L]=13, R=6 a[R]=26, M=5 a[M]=18
k=26 > a[M]=18 往大的那一半找 => L=6 R=6

L=6 a[L]=26, R=6 a[R]=26, M=6 a[M]=26
找到一筆匹配在 M=6 a[M]=26

 

(2-1)在notepad輸入如下JS程式碼並存檔在桌面為bs02.htm

<script>
var a = [1, 13, 5, 26, 7 , 18 , 9];
for (i=0;i<10000;i++) a.push(rand(30000));

a.sort(function(a, b){return a - b;});
document.write("二分搜尋法<br>待搜尋陣列a[]="+a);

bsearch(111);
bsearch(444);
bsearch(1818);
bsearch(2626);

function rand(r){
 var x=Math.random()*r;
 var y=parseInt(x);
 while (a.indexOf(y) >=0) {
    x=Math.random()*r;
    y=parseInt(x);
    }
 return y;
}

function bsearch(k){
    document.write("<hr>數字k="+k+"的搜尋結果如下:");
    var L=0;
    var R=a.length-1;
    var M=parseInt((L+R)/2);
    while (L<=R){
            document.write("<br> L="+L+" a[L]="+a[L]+", R="+R+" a[R]="+a[R]+", M="+M+" a[M]="+a[M]+"");
            if (a[M]==k) {
            document.write("<br> 找到一筆匹配在 M="+ M + " a[M]="+a[M]);
                break;
            }
            else{
                if (k >a[M]) {
                    L=M+1;
                document.write(" 往大的那一半找 ");
                    }
                else {
                    R=M-1;
                    document.write(" 往小的那一半找 ");
                    }
            }
            M=parseInt((L+R)/2);
        }
       if (L>R) document.write("故找不到"+k);
}

</script>

 

(4)用firefox開啟bs02.htm,瀏覽結果如下:

數字k=111的搜尋結果如下:
L=0 a[L]=0, R=10006 a[R]=29999, M=5003 a[M]=14852 往小的那一半找
L=0 a[L]=0, R=5002 a[R]=14850, M=2501 a[M]=7440 往小的那一半找
L=0 a[L]=0, R=2500 a[R]=7437, M=1250 a[M]=3645 往小的那一半找
L=0 a[L]=0, R=1249 a[R]=3644, M=624 a[M]=1808 往小的那一半找
L=0 a[L]=0, R=623 a[R]=1797, M=311 a[M]=868 往小的那一半找
L=0 a[L]=0, R=310 a[R]=866, M=155 a[M]=445 往小的那一半找
L=0 a[L]=0, R=154 a[R]=444, M=77 a[M]=201 往小的那一半找
L=0 a[L]=0, R=76 a[R]=199, M=38 a[M]=87 往大的那一半找
L=39 a[L]=90, R=76 a[R]=199, M=57 a[M]=145 往小的那一半找
L=39 a[L]=90, R=56 a[R]=140, M=47 a[M]=117 往小的那一半找
L=39 a[L]=90, R=46 a[R]=114, M=42 a[M]=104 往大的那一半找
L=43 a[L]=109, R=46 a[R]=114, M=44 a[M]=110 往大的那一半找
L=45 a[L]=111, R=46 a[R]=114, M=45 a[M]=111
找到一筆匹配在 M=45 a[M]=111


數字k=444的搜尋結果如下:
L=0 a[L]=0, R=10006 a[R]=29999, M=5003 a[M]=14852 往小的那一半找
L=0 a[L]=0, R=5002 a[R]=14850, M=2501 a[M]=7440 往小的那一半找
L=0 a[L]=0, R=2500 a[R]=7437, M=1250 a[M]=3645 往小的那一半找
L=0 a[L]=0, R=1249 a[R]=3644, M=624 a[M]=1808 往小的那一半找
L=0 a[L]=0, R=623 a[R]=1797, M=311 a[M]=868 往小的那一半找
L=0 a[L]=0, R=310 a[R]=866, M=155 a[M]=445 往小的那一半找
L=0 a[L]=0, R=154 a[R]=444, M=77 a[M]=201 往大的那一半找
L=78 a[L]=207, R=154 a[R]=444, M=116 a[M]=320 往大的那一半找
L=117 a[L]=321, R=154 a[R]=444, M=135 a[M]=372 往大的那一半找
L=136 a[L]=376, R=154 a[R]=444, M=145 a[M]=415 往大的那一半找
L=146 a[L]=420, R=154 a[R]=444, M=150 a[M]=433 往大的那一半找
L=151 a[L]=435, R=154 a[R]=444, M=152 a[M]=437 往大的那一半找
L=153 a[L]=441, R=154 a[R]=444, M=153 a[M]=441 往大的那一半找
L=154 a[L]=444, R=154 a[R]=444, M=154 a[M]=444
找到一筆匹配在 M=154 a[M]=444


數字k=1818的搜尋結果如下:
L=0 a[L]=0, R=10006 a[R]=29999, M=5003 a[M]=14852 往小的那一半找
L=0 a[L]=0, R=5002 a[R]=14850, M=2501 a[M]=7440 往小的那一半找
L=0 a[L]=0, R=2500 a[R]=7437, M=1250 a[M]=3645 往小的那一半找
L=0 a[L]=0, R=1249 a[R]=3644, M=624 a[M]=1808 往大的那一半找
L=625 a[L]=1812, R=1249 a[R]=3644, M=937 a[M]=2714 往小的那一半找
L=625 a[L]=1812, R=936 a[R]=2712, M=780 a[M]=2233 往小的那一半找
L=625 a[L]=1812, R=779 a[R]=2230, M=702 a[M]=2031 往小的那一半找
L=625 a[L]=1812, R=701 a[R]=2022, M=663 a[M]=1922 往小的那一半找
L=625 a[L]=1812, R=662 a[R]=1920, M=643 a[M]=1860 往小的那一半找
L=625 a[L]=1812, R=642 a[R]=1859, M=633 a[M]=1834 往小的那一半找
L=625 a[L]=1812, R=632 a[R]=1833, M=628 a[M]=1817 往大的那一半找
L=629 a[L]=1821, R=632 a[R]=1833, M=630 a[M]=1822 往小的那一半找
L=629 a[L]=1821, R=629 a[R]=1821, M=629 a[M]=1821 往小的那一半找 故找不到1818


數字k=2626的搜尋結果如下:
L=0 a[L]=0, R=10006 a[R]=29999, M=5003 a[M]=14852 往小的那一半找
L=0 a[L]=0, R=5002 a[R]=14850, M=2501 a[M]=7440 往小的那一半找
L=0 a[L]=0, R=2500 a[R]=7437, M=1250 a[M]=3645 往小的那一半找
L=0 a[L]=0, R=1249 a[R]=3644, M=624 a[M]=1808 往大的那一半找
L=625 a[L]=1812, R=1249 a[R]=3644, M=937 a[M]=2714 往小的那一半找
L=625 a[L]=1812, R=936 a[R]=2712, M=780 a[M]=2233 往大的那一半找
L=781 a[L]=2234, R=936 a[R]=2712, M=858 a[M]=2486 往大的那一半找
L=859 a[L]=2489, R=936 a[R]=2712, M=897 a[M]=2610 往大的那一半找
L=898 a[L]=2611, R=936 a[R]=2712, M=917 a[M]=2668 往小的那一半找
L=898 a[L]=2611, R=916 a[R]=2665, M=907 a[M]=2648 往小的那一半找
L=898 a[L]=2611, R=906 a[R]=2642, M=902 a[M]=2627 往小的那一半找
L=898 a[L]=2611, R=901 a[R]=2626, M=899 a[M]=2616 往大的那一半找
L=900 a[L]=2623, R=901 a[R]=2626, M=900 a[M]=2623 往大的那一半找
L=901 a[L]=2626, R=901 a[R]=2626, M=901 a[M]=2626
找到一筆匹配在 M=901 a[M]=2626


20200120設計可連線LAMP-MYSQL資料庫伺服器並新增資料庫、資料表、資料錄的PHP程式(c1.php)
2020/01/02,13:04

(一)確定LAMP已在WIN10安裝妥當並提供服務,安裝過程詳如:20191224在win10下載、安裝並使用Appserv9.3.0應用程式伺服程式

(二)設計可連線MYSQL並新增資料庫、資料表、資料錄的PHP程式:

(1)在本機用記事本編寫 如下內容並存在c:\appserv\www之中檔名為c1.php

<body bgcolor=LIGHTGREEN>
<?php
function executeSQL($con,$sql){
    if( $query= mysqli_query($con, $sql) ){ echo " [$sql] OK!<br> "; }
    else { echo " [$sql] Failure!<br> "; }
    return $query;
}

$con = mysqli_connect('127.0.0.1', 'root', 'w??????', 'mysql');
if (!$con) { echo "Error"; exit(); }
$sql = 'drop DATABASE selldb;';
executeSQL($con,$sql);

$sql = 'CREATE DATABASE selldb default character set utf8;';
executeSQL($con,$sql);

$sql = 'use selldb;';
executeSQL($con,$sql);

$sql="CREATE TABLE custs (id char(10),name char(20),amount float,tel char(20))";
executeSQL($con,$sql);

$sql = 'set names utf8;';
executeSQL($con,$sql);

$sql="insert into custs(id,name,amount,tel) values ('10001','小狗',156,'08-233375');";
executeSQL($con,$sql);

$sql="insert into custs(id,name,amount,tel) values ('10002','小貓',256,'08-233375');";
executeSQL($con,$sql);

$sql="insert into custs(id,name,amount,tel) values ('10001','小草',1000,'08-233375');";
executeSQL($con,$sql);

$sql="insert into custs (id,name,amount,tel) values ('10002','天牛' ,3000,'03-933375');";
executeSQL($con,$sql);

$sql="insert into custs (id,name,amount,tel) values ('20002','天牛' ,3000,'03-933375');";
executeSQL($con,$sql);

$sql="insert into custs (id,name,amount,tel) values ('30002','天牛' ,3000,'03-933375');";
executeSQL($con,$sql);

$sql= "select id,name,amount,tel from custs";
if( $query= mysqli_query($con, $sql) ){ echo " $sql OK!<br> "; } else { echo " $sql Failure!<br> "; }

while ($row = mysqli_fetch_array($query)){
        echo  $row['id'] . ":" . $row['name'] . ":" . $row['amount'] . "<br>";
}
mysqli_close ($con);

?>

</body>

 

 

(2) 執行c1.php結果如下

[drop DATABASE selldb;] OK!
[CREATE DATABASE selldb default character set utf8;] OK!
[use selldb;] OK!
[CREATE TABLE custs (id char(10),name char(20),amount float,tel char(20))] OK!
[set names utf8;] OK!
[insert into custs(id,name,amount,tel) values ('10001','小狗',156,'08-233375');] OK!
[insert into custs(id,name,amount,tel) values ('10002','小貓',256,'08-233375');] OK!
[insert into custs(id,name,amount,tel) values ('10001','小草',1000,'08-233375');] OK!
[insert into custs (id,name,amount,tel) values ('10002','天牛' ,3000,'03-933375');] OK!
[insert into custs (id,name,amount,tel) values ('20002','天牛' ,3000,'03-933375');] OK!
[insert into custs (id,name,amount,tel) values ('30002','天牛' ,3000,'03-933375');] OK!
select id,name,amount,tel from custs OK!
10001:小狗:156
10002:小貓:256
10001:小草:1000
10002:天牛:3000
20002:天牛:3000
30002:天牛:3000

 

20200102修改lifetype BLOG的summary.php選單
2020/01/02,09:36

(1) $ pwd
/home/webadm/www/lf

 

(2) $ vi templates/summary/header.template
:

<map name="linksmenu" id="linksmenu" title="Navigation">
    <div id="menubar">
        <div id="menu">
          <ul class="menuTop">
             <li class="menuOption"><a href="http://www.kmvs.km.edu.tw">{$locale->tr("kmvsWEB")}</a></li>
             <li class="menuOption"><a href="http://web.kmvs.km.edu.tw/kmvswiki">{$locale->tr("kmvsWIKI")}</a></li>
             <li class="menuOption"><a href="summary.php?op=Summary">{$locale->tr("summary")}</a></li>
             <li class="menuOption"><a href="summary.php?op=Register&amp;start=1">{$locale->tr("register")}</a></li>
             <li class="menuOption"><a href="summary.php?op=PostList">{$locale->tr("posts")}</a></li>
             <li class="menuOption"><a href="summary.php?op=BlogList">{$locale->tr("blogs")}</a></li>
             <li class="menuOption"><a href="summary.php?op=UserList">{$locale->tr("users")}</a></li>
             <li class="menuOption"><a href="http://insecta.idv.tw">{$locale->tr("insecta")}</a></li>
          </ul>
        </div>
    </div>
</map>

 

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType