[Translation] popfly series course 5-List Processing

Source: Internet
Author: User

[Translation] PopflySeries courses5-List Processing: UsePopflyUsePopflyCreate a personalized weather map

Many websites, news broadcasts, and newspapers use weather maps to show temperature and forecast the weather in these cities.

In this lesson, you will learn two different technologies to build your custom meteorological map, where you can draw the temperature and weather forecast information of the city you choose.

List Processing: UsePopflyUsePopflyCreate a personalized weather map

For details about the volume sor popfly mashups in this course, refer:

L weathermap1 (http://www.popfly.com/users/professorpopfly/WeatherMap1)

L weathermap2 (http://www.popfly.com/users/professorpopfly/WeatherMap2)

Learning Outcomes

After completing this course, you should be able:

L list of created and processed data.

L explain the differences between static content and dynamic content.

L separate strings with spaces to create a project list.

L specify the list of information that popfly needs to process for each item.

L append a short string to form a long string.

L draw latitude and longitude information on the map

Overview

Many websites, news broadcasts, and newspapers use weather maps to show temperature and forecast the weather in these cities. In this lesson, you will learn two different technologies to process data to build your custom meteorological map, where you can draw the temperature and weather forecast information of the city you choose.

To create a personalized map, you need to collect meteorological information for each marked city and then mix the data with the map.

This is an example of a map from weather.com.

Http://www.weather.com/maps/activity/travel/usweathertoday_large.html

Weather.com provides their meteorological maps as a service to other information providers. For example, USA Today uses a weather map from weather.com. View the USA Today page at http://www.usatoday.com/weather/temppic/wtempusa.htm. check the bottom right corner of the map and you will notice that the USA Today website directly obtains the temperature map from weather.com.

You can use popfly to create a custom meteorological map by mixing your preferred city and meteorological information and drawing it on a map. The following figure shows the effect of popfly mashup:

Processing list

Weather Map mashup will collect temperature values from several different cities and store them in a list (sometimes called an array ). A list or array describes a set of items that contain the same type of information. The method for processing each item in the list is basically the same: for example, add a group of test data to the list. Find the maximum value of all the stocks in your portfolio, find a volume in an encyclopedia, or print a custom form of no member in your contact. The processing of an item is consistent. The only difference is that the specified information in each project is different.

Popfly is intelligent enough to know whether a block accepts an array of objects as input. The block will process items in the array in the same way.

Data Provider

To build a popfly mashup meteorological map, we need to integrate meteorological data, longitude/latitude data, and a map.

The implementation here uses the Yahoo meteorological block made by sebagomez. (In the block search bar, enterWeather,You can find it. There is more than oneYahoo weather BlockAre you sure you have selected the correct one !) This block has two operations: getweather and getforecast.

The getweather operation returns a yahooweathercondition object containing a title, latitude, longitude, text, temperature, meteorological image (cloud, sun, etc ), and a link to the city meteorological information page of the Yahoo website. Getforecast, another method in the block, returns the current weather of the specified city, the weather forecast for tomorrow, and a link to the meteorological information page of the city on the Yahoo website. This method is not used in meteorological map mashup.

The getweather operation also provides longitude and latitude information, which makes it an excellent choice for creating a weather forecast map. To mark data on a map, you must specify these coordinates. Some blocks provide you with longitude and latitude information. However, in other cases, you need to use the GEONAMES or yahoogeocoding block of popfly in mashup to obtain the longitude and latitude information at the specified position.

Mix and match meteorological data

One way to design this mashup is to use an independent Yahoo meteorological block for each city to mark the map, and then use the combine block to combine Meteorological Results, then, the output of the combine block is passed to Virtual Earth. Participate in: http://www.popfly.com/users/professorpopfly/weathermap1which contains the meteorological map mashup of the metric sor popfly version.

This method is quite straightforward: If you want a map of the three cities, you need three. If you want a map with 6 city weather information, you need 6 pieces.

The Virtual Earth block adds a map nail to each city that combines meteorological information using the merged block.

Note: The combine block of popfly can combine the data of the three blocks that output the same type of information. Combineupto10 can merge up to 10 pieces of data into one list.

The mashup process is summarized as follows:

1. Find the meteorological information of city #1.

2. Search for the meteorological information of city #1.

3. Search for the meteorological information of city #1.

4. merge these results to a list.

5. For each city in the merge results,

A. Place a dingtalk and meteorological information on a map.

Static data vs Dynamic Data

The first example uses a different Yahoo weather block for each city. Before previewing mashup, you need to know how many cities need to be marked on the map.

This solution is "static"-however, weather forecasts are dynamic and the weather forecasts obtained by the city during the preview are not updated. In addition, the number of cities marked on the map is determined at the mashup design, because it is determined by the number of Yahoo weather blocks that make up the mashup.

A more general solution, as shown in the weathermap2 mashup of the login sor popfly, allows users to enter as many postal codes as possible and mark all these cities on the map. In this example, the number of cities and the city itself are unknown before mashup actually runs. In this way, the results are dynamic, because the information that mashup returns to the user is based on the user input.

General Solution

Consider the mashup of popfly for creating a weather map below.

As shown here, the gettext operation of the user input block allows users to enter a series of zip codes, separated by spaces. Popfly only knows that the user inputs a string of characters, but the mashup designer knows that these spaces complete a special task: They separate the zip code entered by the user.

For popfly to interpret spaces in this way, mashup uses the split operation in the text util block to separate user input with spaces and create a zip code list as the result.

Because the output of the split operation is a list, each item in the next block will be operated. Mashup iterates this list to apply the same processing to each item. Because popfly dynamically creates a zip code list when running mashup. It can adapt to any number of postal codes specified by the user. Popfly knows the number of items in the list, so it knows how many times the following steps should be repeated, and each zip code in the list should be executed once.

The processing process of weathermap2 is summarized as follows:

1. the user inputs to obtain the postal code in string format.

2. Separate the zip code information by spaces and place the zip code information in a list.

3. For each zip code in the list:

A. Find the weather in the zip code that represents the region.

B. Place the meteorological information of the region with a map.

Appendix: Add a hyperlink to the illustration number

If you know the tags of super links in HTML, you can add a hyperlink to the Yahoo weather forecast page at the map number. To do this, connect the output of yahooweather to a textappender block and create an HTML hyperlink using the settings below. Use the string output by textappender as the title of the number in the map.

Inside Story: where does the loop happen?

In weathermap2, step a and step B constitute a circular body (a series of repeated commands) to describe how to process each object. If you are familiar with computer programming, you may have learned a "For Loop"-which describes how to iterate each item in the list. Popfly hides any block that accepts the list as input.Source code. For example, clickSwitch to an advancedButton in the block SourceCodeThe implementation of the loop is displayed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.