The Barcode Poem

I wrote this poem a few months ago but I can’t remember the product that inspired it. I just remember that the font all of the text looked different from most of the “back of package” writing I usually see. 

There’s something highly appealing to me about poetry that addresses aspects of technology. And it’s not just poetry. Some of my favorite photography subjects are power poles.

Five Books For Friday #5

I don’t really feel like writing this post today. So I thought I would cheat and just give the titles and maybe a sentence or two for each one. I’m not being lazy, really. Maybe I’m just getting bored with the book list thing. Well, I’ve got a week to think of something more interesting for next week.

  1. Even the Stiffest People Ccan Do the Splits by Eiko. Ok, this one’s the ultimate cheat because I already wrote about it this week in my post Splitsville.
  2. The Playful Way to Serious Writing by Roberta Allen. I really like Roberta Allen. Read this book to find out why. It’s really just a series of writing prompts but with words and images.
  3. Atom Land by Jon Butterworth. Subtitled A Guided Tour Through The Strange (And Impossibly Small) World of Particle Physics, Atom Land uses the concept of building a map of quantum physics to help the reader understand theories and ideas.
  4. Never Turn Your Back on an Angus Cow by Dr. Jan Pol. The life of Dr. Jan Pol, Americas “Favorite Veterinarian”. I haven’t made it through this one yet and I’ve had it for a while. I need to get reading more.
  5. How To Be Perfect by Ron Padgett.  Another collection of poems from Padgett. I didn’t like this one as much as Alone and Not Alone

Splitsville

I love how-to books. There’s something about the promise of learning a new skill, no matter how arcane, useless or difficult, that draws me in.

I was drawn in last weekend at the library by a book called “Even the Stiffest People Can Do the Splits” by Eiko. On the front cover was a slightly smiling woman whose legs were splayed out like the two halves of a gutted fish. To make this scene even more terrifying and mentally disturbing, the woman’s upper torso was lying flat on the floor in front of her apparently rubber pelvis.

I thought this looked fun so I grabbed the book and checked it out along with a couple books of poetry and one on particle physics.

It took me a day or two to finally get around to reading the book. I was avoiding it out of fear I would actually try it. But, as I began to read through it I started thinking maybe I could actually do these creepy and painful looking splits.

There’s probably a reason all of the example models in the book are short, old Japanese women. I figured 41 year old white males who have never been particularly limber aren’t supposed to do the splits. But after only about 30 pages of stretching instructions, the book takes an odd turn and for the next hundred pages or so we’re told a moral splits story that involves two men and a woman.

It’s somewhat difficult to describe the story. One of the men teaches the other man and the woman how to do the splits after they accidentaly interupt him doing the deed in his office. He also teaches them why learning the splits will make them better at their jobs (they work in a trading company) and at life in general. Notable quotes include “Well, you’ve caught me in a compromising position, haven’t you?” and “…you probably ought to slip off your pumps, first”.

I was especially moved by the chapter titled “Light the Fire of the Splits in Your Heart”. I don’t know if it was more painful to get through the book’s stretches or the story.

I’m not totally inexperienced with the splits. I’ve split the seat of my pants a couple of times; I’ve been told “let’s split!” by people cooler than me and I’ve eaten a banana split. But I don’t think any of those life experiences are going to help me rip my groin in half.

A Painful Beginning

And this lady isn’t expecting just the splits. No, she wants me to rest my head on the floor in front of me too. This is like a masochist book or something. But I’m going to give it the old college try.

The book is touted as a four week stretching plan to achieve amazing health. Whatever, I just want to creep people out. I’ll keep you posted for the next four weeks as to my progress.

Upon a Ship


Upon a ship bound for no port
I spied a waiter waiting widely
So I spoke to him in short
I ordered waffles of a sort,
And sat there gazing at the sea
Its breakers breaking snidely.

No waffles came that day I sailed
Though many pancakes sank the bow.
Where was the waiter whom I hailed?
I feel that he has greatly failed
To render service due somehow,
And all I am is hungry now.

Five Books for Friday #4

This week I’ve stacked my five books from smallest to largest and I’ll review them in that order. I considered looking at them from largest to smallest but that seemed psychologically demoralizing. Oh, and when I say small and large I’m referring to width and height and not thickness or number of pages. This has great importance although the reason escapes me.

  1. Walking Your Way to a Better Life by Kimiko is both an inspirational and autobiographical book about a woman who used walking and proper “mental posture” to overcome depression and build an international training business. It’s refreshing to read a book by a Japanese author because their writing rhythm and cadence is so different than western authors. Although, after a while the repitition of a single theme and the sometimes wandering narrative got to me a bit. Also, while I’m a big believer in positive self talk (it can build real neurological pathways in the brain that in turn manifest in your attitude and body) I got really tired reading about the author telling herself that she loves herself.
  2. A Unicorn in a World of Donkeys by Mia Michaels had potential (I always give potential points to unicorn references) but failed to impress. The subtitle is A Guide to Life For All the Eexceptional, Excellent Misfits. Seriously, I get the whole meaning of unincorns and donkeys but she mentioned unicorns and  glowing horns so many times I felt like I was sitting in a pink bedroom surrounded by teacups and teddy bears and a couple of giggling girls who would suddenly curse for no apparent reason. It was a little disturbing.
    “Do you stand in your uniqueness, or do you hide what makes you wonderfully weird?” Mia Michaels
    I know creatives can sometimes be overly dramatic but there’s only so much “You’re amazing and should shoot for the moon” advice I can take.  What’s worse, Michaels organized her chapters into a 12 step program.  Oddly, much of the book read as if it was written for alchoholic mythical creatures.
  3. Next up is the medium sized book In Chocolate We Trust: The Hershey Company Town Unwrapped by Peter Kurie. This was another book I had high hopes for that were never realized. I thought the book was going to be some sort of biographical history of the man, the company and the town. But in the pages I actually read (there was no way I wanted to finish this one) I felt like it was merely a blandly written institutional explanation of what a trust is, why the one that controls the Hershey company is now evil and why “Captalism is bad”. You know what, let’s just move on from this one. I’m getting depressed.
  4. Now we get to my favorite book of the week. To be perfectly honest, I’m not finished with this one yet. But that’s because I’m actually enjoying reading it. If it weren’t for this whole size of book ranking thing this one would have been first, or last. The title is The Secret Life of Pronouns and it’s written by James W. Pennebaker. The premise of the book is that the pronouns we use in our speech and our writing reveal a lot about who we are. The author and his collegues have spent years developing software that can analyze writings and make predictions about the people who wrote them. Pick up the book and at least flip through it. Maybe you won’t discover any life changing conclusions but you might gain a bit of insight into how our words betray us.
  5. The biggest book this week (6 1/4″ x 9 1/4″) is Into the Lion’s Mouth by Larry Loftis. The book is “The true story of Dusko Popov: World War II spy, patriot, and the real-life inspiration for James Bond”. The book is interesting and you can definitely see where Ian Fleming got many of the attributes for Bond. As mentioned in a former post, I’m fascinated by stories of WWII espionage so for me this book was a page turner. However, as in many historical books the documentation of the story sometimes gets in the way of the story itself.  

Well, there you go. Five more books you should either read or run from. 

Toggle Layer Visibility Using URL Parameters in Web App Builder Developer Edition

ESRI’s developer edition of their Web App Builder (WAB) is a handy stand-alone tool for creating web mapping apps. While the WAB is a tool for building an app without needing to code anything, the developer edition allows users to create their own widgets and extend current functionality or themes. Even with this capability, however, there are some situations where the pre-formed development framework just doesn’t go far enough.

This was the situation I found myself in recently when trying to use the WAB to replace our custom built web map viewer at work. Our current viewer interfaces with a few third party apps by accepting url parameters that turn on or off layers and query various layers. The WAB does allow for querying layers using url parameters but it doesn’t have the ability to toggle layers using the url method.

I searched around the internet trying to find someone who has solved this problem but never found a useable solution. ESRI provides url parameter layer visibility functionality on their ArcGIS Online platform but this hasn’t made it to the WAB Developer Edition yet. I’m not sure when or if it will.

Since layer toggling is a must-have functionality for us I decided to work up a solution myself. Thankfully, the developers at ESRI named the WAB’s url handling module mapUrlParamsHandler.js so it was pretty easy to figure out what needed to be modified.

Parameter Modeling

To fix my problem I just had to add one new function. The actual turning on and off of the layers in this function was taken care of by the WAB api. The biggest concern for me was deciding on how the parameters should be passed in the url so they would be easy to use on the client side and easy (and fast) to process on the server.

I considered using the esri ArcGIS Online model of ?layers=show:0,1,2,3 for passing in layer visibility parameters. However, this becomes very cumbersome when considering showing and hiding both layers and sublayers. It would look something like ?layers=show:0,1.0-2-5,3,4;hide:6,7 or some other cryptic looking mash of numbers and characters. I wasn’t even sure the online api accepted a hide parameter. They don’t show one in their documentation.

I then considered using two separate parameters for showing and hiding (?showLayers=1,2,3&hideLayers=1,2,3) but this just adds more complexity to the code on the back side as well as the parameters the client has to plug in. Ultimately I settled on using a single parameter called layers. But then I needed to decide how to reference those layers.

If I used a zero based index url parameter list, then if the layers in the web map ever change position, I’ll have to go in and change the url references to those layers. On the other hand, if I used the titles of the layers, it wouldn’t matter what the index position of the layer is. The name of the layer and the title would still be the same.

It’s true that the title of the layer could change too. In that case we’d still have to update the urls we’re passing in to the app. But in our situation this is less likely to happen than the positon changing. Using titles has another advantage of making it clear to the casual observer exactly what layers are being acted upon. This wouldn’t matter that much since the public isn’t going to be encouraged to pass parameters into the url. But it might be nice for us developers to know what we’re doing.

I ended up using layer titles since they’re human readable and don’t rely on positioning within the web map that drives the web app. However, I created both versions of my modifications so that someone else who wants to use layer indices can do so just as easily.

In my parameter, layers are separated by commas with layers to be shown represented by the layer title (or positive index integers) and layers to be hidden represented by layer titles with a minus(-) symbol in front of them (or negative index integers).

Toggling Sub Layers

I also wanted to be able to toggle sub layers on and off. Sublayers to be toggled will be shown by separating the parent layer from the sublayers with a colon. The sublayers themselves will be separated by semicolons.

In WAB apps, sublayers are 0 index based underneath their parent. Suppose you have an active layer called School Boundaries with a map index position of 6 and it has three sublayers for High Schools, Middle Schools and Elementary Schools. These sub layers would be indexed as 0, 1, 2.

I decided to stick with index references for the sublayers since it was easy to do so and makes sense. It’s also easier to read in and understand within the url since the parent layer is text so there’s some contrast. 

With the above model of building your url for layer toggling, you can take care of almost any layer manipulation scenario you can think of.

This would turn on the Schools layer as well as the first, second and third sublayers: 
?layers=Schools:0;1;2

This would turn off the Schools layer and deselect sublayer 0, then turn the schools back on and select sub layers five and six:
?layers=-Schools:0,Schools:5;6


Multiple Params


Another problem I have with the URL parameter handling capabilities of the Web App Builder is that you can’t add multiple parameters. In other words, you can’t pass in layers to turn on and do a query on a layer at the same time. To solve that problem I just modified the main function in the module to check all url parameters rather than stopping after finding the first one.

mo.postProcessUrlParams = function(urlParams, map){
    //urlParams have been decoded.
    for(var key in urlParams){
      //Loop through the urlParams object
        if(urlParams.hasOwnProperty(key)){
          //For each parameter found, run its function
          if('layers' === key){
            toggleLayers(urlParams, map);
          }else if('extent' === key){
            setExtent(urlParams, map);
          }else if('center' === key){
            setCenter(urlParams, map);
          }else if('marker' === key){
            createMarker(urlParams, map);
          }else if('find' === key){
            sendMessageToSearch(urlParams);
          }else if('query' === key){
            queryFeature(urlParams, map);
          }
        }
    }
  };

How to Use

In order to use the modified mapUrlParamsHandler module in your WAB project you first need to download the appropriate one (index driven or title driven) from Github at https://github.com/RyanDavison/WAB_URL_Parameters. Then replace the native file located in \\WebAppBuilderForArcGIS\server\apps\4\jimu.js .

If you’ve already exported your app and are hosting it on your own server just find the jimu.js folder and paste the file in there. Alternatively you could just copy the code out of the files on Github and paste it right into the native mapUlrParamsHandler.js file. That’s all you have to do to get layer toggling functionality through your url.

In the future, ESRI might enable this same functionality in the WAB Developer Edition. If they do, it’s a good bet they won’t have thhe same url structure as me. As I’m writing this, The Web App Builder is at version 2.9. So if you start using my modified code now, you might be changing your own url structures to match the ESRI api. My modifications 

If you have and questions, comments or problems feel free to leave them in the comments section below or contact me on Github.

EDIT:
When I first wrote the modification You could only turn sub layers on and off along with their parent layer. So, if you wanted to turn off sub layer 2  but turn on sub layer 3 of LayerX you would have to write

?layers=-LayerX:2,LayerX:3

It was a two-step process that was very clunky. Now, you can turn off sublayers independently. So the query above would now simply read:

?layers=LayerX:-2;3

Of course you can still turn off an entire layer like this:

?layers=-LayerX