What is the height restriction for a building and how is it measured?

The height restriction in the Town of Scituate is 35', max 40' to the top of the ridge.  The distance measured vertically from the average finished grade of the ground adjoining a building to the highest point of the roof for flat roofs, to the deck line for mansard roofs, and to the average height between eaves and ridge for gable, hip and gambrel roofs except that in Residential Zoning Districts, there shall also be a maximum height measured from the average finished grade to the ridge for a building with a gable, hip or gambrel roof.