WordPress and the Map Editor

This represents the integration of the map editor into a WordPress plugin.

The shortcode produces a “viewer” version of the map editor for a post or page.

Creating and editing of maps is performed in the WordPress admin facilities.

Example of IBS Map Viewer

Click on a blue square to see options.

Finally Feeling Like An Update

Been a while getting around to the point of feeling like doing an update. The second B&M Luxos has arrived and indeed it is the latest version with the fixed handlebar cable with switch. Nice as that eliminates the moisture issue related to the plug in version. Bought from bike24.com for about $100.00 less than one from Peter White.

I still need to figure out how to mount it on the Bruce Gordon since there is no mounting hole on the fork. I’ll need to drill a 10 mm hole and jury rig a threaded stud to mount the light at the fork crown.

 

Hub Dynamo USB Charger

I have finished the build of the USB charger using the kit I had bought off EBay. As planned everything worked out quite well and it readily charges my booster battery pack. However the Droid will not charge but this is probably due to not incorporating the data circuitry needed.

The super capacitor circuitry worked fine and would keep charging the battery pack for about 5 minutes after the wheel stopped rotating. But found the charger had a large enough capacitor without the added circuitry to smooth out the fluctuations.   If I needed a stand-light the super-capacitor would be ideal.

I believe if I powered a “minty booster” with the charger I could readily and reliably charge smart phones, Android, Apple and Windows. Add the super-capacitor circuit between the charger and a “minty booster” it could really be a robust solution.

As a note I moved the Stanyan around the garage, not more than 20 feet and both the tail light and Luxos U stand-lights popped on for quite a long time. Awesome. That says something for the SON Hub Dynamo.

I am waiting for another Luxos U to arrive from Germany to go with the Shimano dynamo hub on the Bruce Gordon. The price was very good, about the same as the non-usb B model here in the States. That may because it is first generation with a plugable switch/usb cord. I have read that these units have a moisture problem. Also it seems there were problems of parts availability. The new lights come with hardwired switch/usb cords.

 

Map Editor – GPX Data

Until now I did not give much thought to using and saving GPX data. I was able to do what I wanted  and I was a happy camper. Now that I am working more with the ACA GPX files I have dug into the GPX XML specifications. I had to make modifications to the way I was handling the data.

As I understand the GPX files, the basic foundation is the waypoint-type (a variant of the point-type) which describes  waypoints, points of interest, and geographic features. The two attributes, longitude and latitude, defines the geographic location. The encapsulated data in the waypoint goes onto to more fully define the various aspects and properties of the waypoint-type.

Looking at an ACA GPX file with resources the is many waypoints, and not points of interest or other waypoints. These waypoints are again found in the <rte> sections as <rtept> entries. The ACA GPX files don’t seem to have a <trk><trkseg><trkpt> section as I believe they were developed using maps and not a gps device.

However if there was a <trk><trkseg> section the waypoints would show up again as <trk><trkseg><trkpt> entries. So theoretically the <rte> and <trkseg> could be construed to be synonymous. But there are limits to the number of route points allowed for Garmin devices. Subsequently the <trk> <trkseg> would be a sparse track.

The goal is to use the ACA GPX route files to create a viable track section with directional waypoints and cue sheets. The ACA waypoints are non directional. No right turns or left turns as they serve both directions of travel.

 

Map Editor Updated.

The latest version of the Map Editor may be found here. It is opened with a RMB click on “Map.” An overview video may be found here.

This final version seems to work quite well on my Nexus 7 tablet using a stylus pen. The RMB simulated with a long press functions correctly. At this time there is not a viewer only version.

Bruce Gordon Rebuild II

Almost done with the BG rebuild and it is ending up pretty much in the same form as I started with. Except it is black instead of red. In the end just could not get the cantilever brkes to work as I wanted them to so I used Tektro RX5 V-Brakes both front and back. On the back at 85 mm arm length they just clear the fender but up front there is plenty of clearance. They set up nicely with the Tektro RL520 levers.

Rebuilt the front wheel (A 719) with DT Competition double butted spokes and alloy nipples on a Shimano Dynamo Hub. I was thinking about a Shutter Precision hub (~$130) or even another SON28 (~$280) but found the Shimano DH 3N71 for $78.00. Which was too much of a savings to pass up.

Played with the idea of going to a flat bar briefly but the bike is designed for drop bars and bar end shifters so I stayed with that configuration in the end.

The saddle, for now, is my old Brooks Professional (not to be confused with Team Pro) which was made briefly the late last century. Essentially a B 17 without saddlebag hoops but made of a very heavy black leather and large rivets.

 

Hub Generator – USB

For the rebuild of the Bruce Gordon I am working on implementing my own hub-generator – USB charger. Why? Well I am not entirely happy with the BM Luxos U headlamp that comes with an integrated USB charger port. The USB connector is integrated into the handle bar light switch and for what I want to do that makes the wiring messy and cluttered. Also I think the handle bar switch adds a level of unnecessary complexity and points of failure. So I am going back to a simpler set up for the light and charger.

Switch between lights and charging instead of trying to do both at once.

A large lithium battery pack charged off the hub will be used to recharge the Garmin 500 off line each day.

I have ordered two of these kits at $8.00 each from Amazon.

kit-1

 

 

Fundamentally this is the same circuit I have been experimenting with except the full wave bridge rectifier is made of discrete 1N4007 diodes instead of a single integrated circuit component. Nice thing is the PC board which alone is worth the price of the kit.

kit-3

supercap-charge

Update 12-05-13

Found the above circuit to add a super-capacitor as a backup to the hub dynamo during stops. I will be using two super caps in series to get the 5v for the USB port. Also looking to add the necessary components to handle the Apple gear.

I have ordered 1N5822 3A Schottky diodes to replace the 1N4007 diodes to reduce the voltage loss across the bridge. Will use a low drop out (LDO) voltage regulator instead of the one that comes with the kit.

 

 

Rebuilding The Bruce Gordon

I have torn down the Bruce Gordon to have the frame, fork, stem, and racks powder coated in a gloss black.

Going to try Microshift bifters in lieu of the bar ends. I just cannot like the bar ends even though I can not find a fault with them. I had bought two pair of the Mircoshift bifters when they were on sale a couple years ago at Performances as I knew 9 speed was going to be hard to come by. Sure enough I have looked high and low for Ultegra and 105 9 speed bifters and none to be found. I do have a old pair of first generation 105′s but they were not reliable enough to put on a touring bike. The new 10 speed stuff isn’t compatible between road and mtb as the 9 speed are.

I am replacing the headset, crank set and brakes. I really don’t like cantilever brakes preferring the V brakes since they are a more simple to set up and have stronger braking then the cantilevers, in my opinion. But they don’t play well with road levers without an extra gizmo.

Changing over to the cantilevers(Shimano CX50) means I now have to have cable hangers. The fork is cut tight to the headset so there isn’t much left to put a cable hanger in there. I did find a 1″ Ritchey headset with a 33.0 mm stack height to replace the Ultegra headset which had a 33.5 mm stack height. This .5 mm should give me room for a front cable hanger.

The back cable hanger is another iffy situation too. The newer Bruce Gordon’s have a built in cable hanger. Mine however requires a separate cable hanger dangling off the seat post clamp. Not really cool.

The current crank is an ancient XT square taper. I found a Delore FM 591 with the outboard bearing bottom bracket. The new crank is heavier with steel chain rings and has a bash guard. But it is 9 speed and with the right chain rings, 44-32-22.

Update

I have decided to stay with the “classic” touring set up of bar ends and cantilever brakes. That is the way the bike is designed and any other set up compromises one thing or another. It was fine on the Trans Am for 2,000 + miles and the bike fits well.

Recurring Events – Server Side

Most people tend to make recurring events far more complicated then they need to be. In the case of my imaginary job scheduling calendar I have one MYSQL table to store events. In the table structure there is one “repeat” field defined as “text.” The reason for using text will become apparent as we walk through the framework for recurring events;

The repeat field stores a string that defines the recurrences and exceptions to it. Structurally the string is a series of characters much like a binary masks in sections delimited with semi-colons “;” and looks something like this;

  • J F M A M J J A S O N D;      month(s)
  • 1 2 3 4 L;      weeks of the month
  • S M T W T F S; days of the week
  • 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1; dates of the month
  • D W M; interval unit of days, weeks, or months
  • 999; number of interval units
  • D D; whether using day of week or dates of month
  • start date;
  • end date;
  • first exception date;
  • …..
  • last exception date

With PHP it is easy to explode this string into a array of sections and finally use split_str to blow each section into the arrays like moy, dom, wom, dow and so forth. In general the repeat matching is rather straight  forward except for determining the last day of week in a month.

matchRepeat($date, $repeat)

$date in repeat range of start - end
  $date is not an exception date.
    pattern && month matches
      day and not date && week of month matches && day of week matches true
      date and not day && date of month matches true
    interval (using DateTime and DateInterval)
     days    days % number == 0 true
     weeks   (days / 7) % number == 0  && days of week matches true
     months  months % number == 0
        day not date && week of month matches && day of week matches true
        date and not day && date matches true

Responding to the request for events;

1 Do a database query for requested events

SELECT * FROM `events` where `start` >= $start AND `end` <= $end AND `repeat` IS NULL;
foreach($event in $events)
     $result[]= calendarEvent($event);

2 Do a database query for recurring events;

SELECT * FROM `events` where `repeat` IS NOT NULL;       
foreach($event in $events){
            $test = $start;
            while ($test < $end)
                  if(matchRepeat($test, $event->repeat)
                          $result[] = calendarEvent($event->id); // all will have same id
                  $test += 86400;
            }
}

 

3 Get holiday events;

 

4 Output events for FullCalendar;

header("Content-Type: application/json; charset=UTF-8");
echo json_encode($result);
exit;

5 Handling Recurring Event Updates and Changes;

$id = $_REQUEST['id'];
$start = $_REQUEST['start'];
$end = $_REQUEST['endt'];
$event = new event($id); //fetch event from database;
if($event->repeat && $event->start !== $start){
       $cloned = event::spawn($event, $start, $end); // new event with its own unique id
       $event->repeat += ';' . $cloned->start; //record exception
       $event->updateEvent();
}

 

Recurring Events – FullCalendar

I have been developing, for grins, a job scheduling calendar for an imaginary landscaping company using FulllCalendar with a WordPress plugin as the backend. One of the more common problems encountered is recurring events. First issue is an interface for the user to define the recurrences and second is processing them.

From my perspective recurrences are a combination of a pattern and an interval. Perhaps there is a case for a hybrid of the two too.

Thus a recurrence can be defined in terms of months of the year (moy), weeks of the month (wom), and days of the week (dow), An example is Thanksgiving Day; “Every year the last Thursday of November”, moy = November, wom = last and finally the dow = Thursday.

Another common recurrence is Christmas which also occurs annually on the 25th of December or day 25 of the month of December (dom) 

We can use these arrays to define the recurrences

  • moy array(0..11)  of bool
  • dom array(0..30) of bool
  • wom array(0..4) of bool note array[4] set alone (0001) indicates the last dow for the month.
  • dow array(0..6) of bool

Next adding an interval unit array(0..3) for days,weeks, and months coupled with a multiplier value we can round out the necessary elements to define recurrences.

The following views show the user interface to define recurring events;

repeat-1.png

This above is the default view expressing the event start date. This a pattern that does not have an explicit interval.

repeat-2.png

This is a weekly interval recurring event view where the days of the week can be set. Thus the week can have a pattern for the days of the week.

repeat-3.png

This is an event with a monthly occurrence where the weeks of the months and days of the month may be set.

repeat-4.png

This is another event with a monthly occurrence but here the dates of the month may be selected.